如何通过pip安装mysql-connector-python(开发版)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31748278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you install mysql-connector-python (development version) through pip?
提问by Aivoric
I have a virtualenv in which I am running Django 1.8 with Python 3.4
我有一个 virtualenv,我在其中使用 Python 3.4 运行 Django 1.8
I am trying to get support for MySQL however I am having trouble getting the different connectors to work. I have always used mysql-connector-python with django 1.7 and would like to continue using it.
我正在尝试获得对 MySQL 的支持,但是我无法让不同的连接器正常工作。我一直在 django 1.7 中使用 mysql-connector-python 并希望继续使用它。
The development version of mysql-connector-python (2.1.2) seems to have support for Django 1.8 now.
mysql-connector-python (2.1.2) 的开发版现在似乎已经支持 Django 1.8。
How do I install the development version using pip install (within my virtualenv)? I have tried running the following command:
如何使用 pip install(在我的 virtualenv 中)安装开发版本?我试过运行以下命令:
pip install mysql-connector-python==2.1.2 --allow-external mysql-connector-python
but the 2.1.2 developer version is not available there:
但 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
I have tried downloading the file directly from: http://dev.mysql.com/downloads/connector/python/
我尝试直接从以下位置下载文件:http: //dev.mysql.com/downloads/connector/python/
...but for some reason after installation the connector is not available within my virtualenv
...但由于某种原因安装后连接器在我的 virtualenv 中不可用
Help please :-) Thank you. '
请帮助:-) 谢谢。'
EDIT:I have tried
pip install mysql-python
but it is not supported by Python 3.4
编辑:我已经尝试过,
pip install mysql-python
但 Python 3.4 不支持它
采纳答案by rotten
I agree, the debian packages appear to be broken for at least Ubuntu 14.04.
我同意,至少 Ubuntu 14.04 的 debian 软件包似乎已损坏。
The apt-get version and the pip version do not include the 2.1.x releases.
apt-get 版本和 pip 版本不包括 2.1.x 版本。
To get it done, I had to grab the source:
为了完成它,我必须获取源代码:
$ 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'
>>>