我只是尝试使用here提供的非常简单的说明来简单地安装python-myconnector
.
但它失败了。这是我得到的错误:
(my_virtual_env) [my.username@my_machine ~]$ pip install mysql-connector
...
Command "/home/my.username/my_virtual_env/bin/python2.7 -u -c
"import setuptools, tokenize;
__file__='/tmp/pip-build-rLJbLN/mysql-connector/setup.py';
f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');f.close();
exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-mFh5Pg-record/install-record.txt
--single-version-externally-managed
--compile
--install-headers
/home/me/my_virtual_env/include/site/python2.7/mysql-connector"
failed with error code 1 in /tmp/pip-build-rLJbLN/mysql-connector/```
可以找到完整的错误日志 here如果您需要查看它(但我怀疑您会)
为什么会发生这种情况以及如何解决它?另外,仅供引用,我在这台机器上没有 sudo 访问权限。这就是我将其安装到虚拟环境中的原因..
仅供引用,似乎它应该在 /tmp/pip-build-rLJbLN/
中写入一些内容,但没有写入,然后当它尝试读取内容时它会爆炸应该早些时候写过。那么我该如何修复这个错误呢?
我已经阅读了其他类似问题的其他解决方案here 。但我无法让他们中的任何一个为我工作。
最佳答案
mysql-connector明确指出它需要protobuf
mysql-connector (version >= 2.2.3) requires Protobuf C++ (version >= 2.6.0)
正如我评论的那样,您的错误日志坚持相同:
Line 81, 165: Unable to find Protobuf include directory.
根据您的平台,请遵循此 protobuf C++ installaion instruction ,并导出 protobuf 路径,以便 pip 可以引用该路径
关于python - 为什么 pip install mysql-connector 失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47709703/