如何通过pip安装mysql connector python(开发版本)?

2024-05-23 15:50:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个virtualenv,我在其中使用python3.4运行Django 1.8

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

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不支持它


Tags: installpipdjango命令版本connectorvirtualenv开发人员
1条回答
网友
1楼 · 发布于 2024-05-23 15:50:30

我同意,至少在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'
>>>

相关问题 更多 >