pip install mysql-connector == 2.1.3失败

时间:2016-07-22 11:09:12

标签: python mysql pip

(ENV)$ pip install mysql-connector==2.1.3
Collecting mysql-connector==2.1.3
  Using cached mysql-connector-2.1.3.zip
Installing collected packages: mysql-connector
  Running setup.py install for mysql-connector
    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
    Complete output from command /<DIR>/ENV/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ImtJft/mysql-connector/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FN9lfq-record/install-record.txt --single-version-externally-managed --compile --install-headers /<DIR>/ENV/include/site/python2.7:
    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 "/<DIR>/ENV/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ImtJft/mysql-connector/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FN9lfq-record/install-record.txt --single-version-externally-managed --compile --install-headers /<DIR>/ENV/include/site/python2.7" failed with error code 1 in /tmp/pip-build-ImtJft/mysql-connector

这是错误。我一直试图找出错误。我做了一些搜索,但没有用。我正在运行Fedora 22.我检查了是否可以安装MySQL。但是已安装mysql-develmysql-libs。请帮忙。

编辑:我试过了:

easy_install mysql-connector==2.1.3

它有效。但为什么pip失败?

2 个答案:

答案 0 :(得分:2)

您的setuptools版本可能已过时。 尝试升级pip:

pip install --upgrade setuptools

您可以在此主题中找到有关此错误的信息:

What does "error: option --single-version-externally-managed not recognized" indicate?

答案 1 :(得分:0)

我认为这是一个老问题,但错误似乎在每次mysql-connector升级时重复,我从以下位置下载源代码:

https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.6.tar.gz

解压缩并进入该文件夹并应用:

sudo python setup.py install

恕我直言,我认为问题,至少在我使用macOS的情况下,是最近安装的Xcode。