【问题标题】:Error installing mysql-connector-python on Amazon Linux AMI via pip-3.4通过 pip-3.4 在 Amazon Linux AMI 上安装 mysql-connector-python 时出错
【发布时间】:2016-12-11 20:35:07
【问题描述】:

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

我正在尝试在 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'))

我不知道该怎么做,任何帮助将不胜感激。

【问题讨论】:

    标签: python mysql amazon-ec2 pip


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    • 2015-04-28
    • 2015-10-23
    • 2014-06-03
    • 1970-01-01
    • 2015-05-05
    相关资源
    最近更新 更多