我无法使用pip安装mysql连接器python

我无法使用pip安装mysql连接器python,pip,pypi,mysql-connector-python,Pip,Pypi,Mysql Connector Python,我正在尝试安装mysql连接器python==1.0.12,作为项目自动安装的一部分,我从pip安装中得到以下错误: Collecting mysql-connector-python==1.0.12 (from -r /tmp/requirements.txt (line 20)) Could not find a version that satisfies the requirement mysql-connector-python==1.0.12 (from -r /tmp/requir

我正在尝试安装
mysql连接器python==1.0.12
,作为项目自动安装的一部分,我从
pip安装中得到以下错误:

Collecting mysql-connector-python==1.0.12 (from -r /tmp/requirements.txt (line 20))
Could not find a version that satisfies the requirement mysql-connector-python==1.0.12 (from -r /tmp/requirements.txt (line 20)) (from versions: )
No matching distribution found for mysql-connector-python==1.0.12 (from -r /tmp/requirements.txt (line 20))
直到几天前,它还运作良好。我调查了一下,发现了以下几点。具体而言,以下日期为2015年12月28日的评论:

根据PEP 470,使用PyPI链接到一个包时,应该为空 由PyPI托管,供自动安装程序下载(the/simple)/ 索引)已弃用并计划删除。系统的维护者 受影响的软件包在3个月前通过电子邮件发送。搬迁发生了 今天早些时候(一个bug导致了一些像Twisted这样的垃圾,它们是 托管在PyPI上,也会删除它们的链接,但这已经被删除 补救)。MySQL连接器python的维护者应该 上传到PyPI或指导其用户使用-f或 --额外的索引url及其维护的存储库

如何让安装的
mysql连接器python==1.0.12
顺利运行?
我需要设置自己的存储库吗?

有很多解决方案,例如托管私有存储库,但最快的方法是将
requirements.txt
文件更改为从mysql的cdn下载

i、 例如,改变:

mysql-connector-python==1.0.12


对于所有像我这样懒惰的人来说,他们不得不用谷歌搜索需求文件的工作原理

就这么做吧…

echo https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz >> requirements.txt
然后这个

sudo -H pip install -r ./requirements.txt
检查一下

pip list | grep mysql
它应该输出:

mysql-connector-python (2.1.3)

如果您使用的是
setup.py
脚本,请将依赖项列在
install\u requires
中,但将属性
dependency\u links
添加到带有列表的安装函数中,并将程序包的url放在其中。例如:

setup(
    dependency_links=['http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip']
)

文档中指定了更多内容。

以上链接对我无效,或者在尝试安装到AWS Beanstalk时无效。但以下链接确实起了作用:

https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df
为我工作使用

pip安装mysql连接器python-rf

更多信息请点击此处

Red Hat/CentOS
对于其他操作系统,请参见

@Ammon您能用https下载链接更新您的答案吗?由于安全原因,https是更好的选择-2.1.3版现在可以编辑选择我需要执行的最新版本http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip
以获得最新版本。如果有cdn链接,请更新该链接。除此之外,下面的答案似乎效果更好:pip安装mysql连接器python rf这个答案为我节省了很多时间
https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df
sudo yum install python-devel mysql-devel
sudo pip3 install mysql-connector