Win64安装MySQL-python

在Win64环境下使用pip安装MySQL-python 1.2.5,报错:

> pip install MySQL-python
Cannot open include file: 'config-win.h': No such file or directory

安装步骤如下:

安装 Microsoft Visual C++ Compiler Package for Python 2.7

下载文件:VCForPython27.msi
下载链接:http://www.microsoft.com/en-us/download/details.aspx?id=44266

安装 Mysql Connector,选择安装64位的

下载文件:mysql-connector-c-6.0.2-winx64.msi
下载链接:https://dev.mysql.com/downloads/connector/c/6.0.html

下载 MySQL-python 1.2.5 源码包(一定要使用源码安装)

下载文件:MySQL-python-1.2.5.zip
下载链接:https://pypi.python.org/pypi/MySQL-python/1.2.5

解压源码包后,修改 site.cfg 文件

实际上,如果是在32位系统上部署,那么直接通过pip install 安装MySQL-python 1.2.5 只需进行上面的依赖包安装即可。
但在 64 位环境中,就会提示 Cannot open include file: 'config-win.h' 错误。原因就是 site.cfg 中配置的 MySQL Connector C 为32 位版本。

原来的 site.cfg 文件内容如下:

# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2

修改为:

connector = C:\Program Files\MySQL\MySQL Connector C 6.0.2

运行 python setup.py install 即可安装完成。

安装MySQL数据库驱动

PyMySQL: https://pypi.python.org/pypi/PyMySQL

> pip install PyMySQL
上一篇 Windows下Python2.7和Python3共存
下一篇 Python 3 环境配置
目录
文章列表
1 Flutter Widget之GridView
Flutter Widget之GridView
2
React Native学习之安装Nuclide与AlertIOS API
React Native学习之安装Nuclide与AlertIOS API
3
ARouter解析之基本使用
ARouter解析之基本使用
4
Appium自动化测试(6)—— python-client安装与测试
Appium自动化测试(6)—— python-client安装与测试
5
grafana-cli命令
grafana-cli命令
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。