提前道歉如果这是一个简单的解决方案,我已经搜索了答案,但没有运气。
我正在尝试在Amazon的Linux AMI上安装mysql-connector-python包。出于我的目的,我想使用Python3.4。我已经用yum安装了Python 3.4和pip-3.4,并且已经成功安装了几个包:
pip-3.4 list给出
numpy (1.11.1)
pip (6.1.1)
setuptools (25.1.4)
virtualenv (15.0.2)然而,当我尝试的时候:
sudo pip-3.4 install mysql-connector-python我得到了
Collecting mysql-connector-python
Could not find a version that satisfies the requirement mysql-connector-python (from versions: )
No matching distribution found for mysql-connector-pythonsudo pip-3.4 install mysql-connector-python --allow-external mysql-connector-python给出了相同的错误。谷歌搜索建议我使用sudo pip-3.4 install mysql-connector-python-rf --allow-external mysql-connector-python-rf,但随后会出现以下错误:
Collecting mysql-connector-python-rf
Using cached mysql-connector-python-rf-2.1.3.tar.gz
Installing collected packages: mysql-connector-python-rf
Running setup.py install for mysql-connector-python-rf
Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-hotls6f7/mysql-connector-python-rf/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wzpbgx5g-record/install-record.txt --single-version-externally-managed --compile:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: option --single-version-externally-managed not recognized
----------------------------------------
Command "/usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-hotls6f7/mysql-connector-python-rf/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wzpbgx5g-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-hotls6f7/mysql-connector-python-rf我尝试了很多方法,比如
echo https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz >> requirements.txt
sudo -H pip-3.4 install -r ./requirements.txt这给出了一个类似的错误,
sudo pip-3.4 install https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz这给出了相同的error: option --single-version-externally-managed not recognized错误。我还应该注意到,pip建议我使用sudo pip-3.4 install --upgrade pip进行升级,但当我这样做时,即使是pip-3.4 list或pip-3.4 --version也会给我pkg_resources.VersionConflict: (pip 8.1.2 (/usr/local/lib/python3.4/site-packages), Requirement.parse('pip==6.1.1'))。
我有点不知所措,如果有任何帮助,我将不胜感激。
发布于 2016-08-05 20:35:41
在这里回答我自己的问题时,我知道它不能直接解决我的问题,但我已经设法安装了mysql-connector,以便在Python3(.4)中,import mysql.connector不会给出任何错误。下面是我所做的:
wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df
unzip mysql-connector-python-2.0.4.zip
cd mysql-connector-python-2.0.4
sudo python3 setup.py install现在,在Python3中:
>>>import mysql.connector
>>>我仍然很好奇,为什么我之前得到了错误error: option --single-version-externally-managed not recognized。我猜这是setuptools的问题,但我已经把它升级到了最新的版本(以及virtualenv)。
https://stackoverflow.com/questions/38789039
复制相似问题