gpt4 book ai didi

python - 通过 pip-3.4 在 Amazon Linux AMI 上安装 mysql-connector-python 时出错

转载 作者:行者123 更新时间:2023-11-29 04:37:01 26 4
gpt4 key购买 nike

如果这是一个简单的解决方法,请提前致歉,我已经搜索了没有运气的答案。

我正在尝试在 Amazon 的 Linux AMI 上安装 mysql-connector[-python] 包。出于我的目的,我想使用 Python 3.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-python

sudo 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 完全中断,甚至 pip-3.4 listpip-3.4 --version 给我 pkg_resources.VersionConflict: (pip 8.1.2 (/usr/local/lib/python3.4/site-packages), Requirement.parse('pip= =6.1.1'))

我有 pip 不知所措,非常感谢任何帮助。

最佳答案

在这里回答我自己的问题,我知道它不能直接解决我遇到的问题,但我设法安装了 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)。

关于python - 通过 pip-3.4 在 Amazon Linux AMI 上安装 mysql-connector-python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38789039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com