【问题标题】:How do you install mysql-connector-python (development version) through pip?如何通过pip安装mysql-connector-python(开发版)?
【发布时间】:2015-10-23 06:10:26
【问题描述】:

我有一个 virtualenv,我在其中运行 Django 1.8 和 Python 3.4

我正在尝试获得对 MySQL 的支持,但是我无法让不同的连接器正常工作。我一直使用 mysql-connector-python 和 django 1.7 并希望继续使用它。

mysql-connector-python(2.1.2)的开发版现在好像已经支持Django 1.8了。

如何使用 pip install(在我的 virtualenv 中)安装开发版本?我试过运行以下命令:

pip install mysql-connector-python==2.1.2 --allow-external mysql-connector-python

但那里没有 2.1.2 开发者版本:

could not find a version that satisfies the requirement mysql-connector-python==2.1.2 (from versions: 1.1.4, 1.1.5, 1.1.6, 1.2.2, 1.2.3, 2.0.1, 2.0.2, 2.0.3, 2.0.4)
  Some insecure and unverifiable files were ignored (use --allow-unverified mysql-connector-python to allow).
No matching distribution found for mysql-connector-python==2.1.2

我试过直接从http://dev.mysql.com/downloads/connector/python/下载文件

...但由于某些原因,安装后连接器在我的 virtualenv 中不可用

请帮忙 :-) 谢谢。 '

编辑: 我努力了 pip install mysql-python 但 Python 3.4 不支持它

【问题讨论】:

    标签: python mysql django


    【解决方案1】:

    我同意,至少 Ubuntu 14.04 的 debian 软件包似乎已损坏。

    apt-get 版本和 pip 版本不包括 2.1.x 版本。

    为了完成它,我必须抓住源头:

    $  git clone https://github.com/mysql/mysql-connector-python.git
    $  cd mysql-connector-python
    $  python ./setup.py build
    $  sudo python ./setup.py install
    
    ...
    
    >>> import mysql.connector as msc
    >>> msc.__version__
    '2.1.3'
    >>>
    

    【讨论】:

    • 这似乎也适用于我在 OSX 上的 virtualenv。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 2017-12-03
    • 2016-12-11
    • 2016-04-02
    • 2016-05-12
    • 1970-01-01
    相关资源
    最近更新 更多