python 安装 mysql-python遇到的问题
2016-05-06 10:19
686 查看
先通过 pip install mysql-python 报错后来下载安装,报错:File "setup.py", line 15, in <module>metadata, options = get_config()File "F:\devtools\MySQL-python-1.2.3\setup_windows.py", line7, in get_configserverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options[' registry_key'] )WindowsError: [Error 2] The system cannotfind the file specified下载地址:https://pypi.python.org/pypi/MySQL-python/下载MySQL-python-1.2.5.zip 文件之后直接解压。进入MySQL-python-1.2.5目录:>>python setup.py install解决方法:其实分析代码,发现只是寻找mysql的安装地址而已 修改setup_windows.py如下注解两行,加入一行,为第一步mysql的安装位置#serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,options['registry_key'] )#mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')mysql_root = r"F:\devtools\MySQL\MySQL Server 5.5"然后报错: Unable to find vcvarsall.bat最后去加州大学 欧文分校的Christoph Gohlke提供了大量python非官方 插件模块安装包:
www.lfd.uci.edu/~gohlke/pythonlibs/还是有问题,在虚拟环境中手工又装了一遍mysql_python, 报错如下:error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get
it from http://aka.ms/vcpython27
下载安装vcpython27后,报错:_mysql.c(34) : fatal error C1083: Cannot open include file: 'config-win.h': No s
uch file or directory1)问题 : _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2原因 :原因是安装MySQL的时候没有安装C语言库。解决 :重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。检查已经安装上了。继续解决报错:LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
error: command '"C:\Users\pccw\AppData\Local\Programs\Common\Microsoft\Visual C+
+ for Python\9.0\VC\Bin\link.exe"' failed with exit status 1181
可能会出现找不到 config-win.h的提示,我的MySQL的版本是5.6.13
对于这个问题,首先检查MySQL-python 1.2.5目录下的site.cgf文件
#connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.1
connector的配置是否正确,如果跟自己系统的情况不符,改成你系统的实际目录
如果没有安装 MySQL-connector,去MySQL网站上下载安装。
其次,修改_mysql.c文件
把包含config-win.h修改成my_config.h
//#include <config-win.h>
#include <my_config.h>
OK,编译,如果后面提示mysqlclient.lib找不到。
把setup_window.py的下面一句修改
library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
指向正确的mysqlclient.lib路径,我的系统的路径是
library_dirs = [ os.path.join(mysql_root, r'lib\vs10') ]记得mysql_root的路径也要改,mysql_root=r"C:\Program Files\MySQL\MySQL Connector.C 6.1"
再编译OK。
www.lfd.uci.edu/~gohlke/pythonlibs/还是有问题,在虚拟环境中手工又装了一遍mysql_python, 报错如下:error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get
it from http://aka.ms/vcpython27
下载安装vcpython27后,报错:_mysql.c(34) : fatal error C1083: Cannot open include file: 'config-win.h': No s
uch file or directory1)问题 : _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2原因 :原因是安装MySQL的时候没有安装C语言库。解决 :重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。检查已经安装上了。继续解决报错:LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
error: command '"C:\Users\pccw\AppData\Local\Programs\Common\Microsoft\Visual C+
+ for Python\9.0\VC\Bin\link.exe"' failed with exit status 1181
解决方法:
可能会出现找不到 config-win.h的提示,我的MySQL的版本是5.6.13
对于这个问题,首先检查MySQL-python 1.2.5目录下的site.cgf文件
#connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.1
connector的配置是否正确,如果跟自己系统的情况不符,改成你系统的实际目录
如果没有安装 MySQL-connector,去MySQL网站上下载安装。
其次,修改_mysql.c文件
把包含config-win.h修改成my_config.h
//#include <config-win.h>
#include <my_config.h>
OK,编译,如果后面提示mysqlclient.lib找不到。
把setup_window.py的下面一句修改
library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
指向正确的mysqlclient.lib路径,我的系统的路径是
library_dirs = [ os.path.join(mysql_root, r'lib\vs10') ]记得mysql_root的路径也要改,mysql_root=r"C:\Program Files\MySQL\MySQL Connector.C 6.1"
再编译OK。
相关文章推荐
- python 内建函数basestring笔记
- Python使用UUID库生成唯一ID
- 杂记_一些关于python代码风格汇总_不断更新
- hash加密 python
- 基于python sqlite3将KDD-99数据集插入数据库中
- Python selenium爬虫
- 使用python将KDD-99中的文本替换为数值形式
- 基于python一个分发小脚本
- python str和repr的区别
- Python标准库:内置函数eval(expression, globals=None, locals=None)
- python日志记录-logging模块
- python切片详解
- Python_爬虫
- Python 装饰器
- python中matplotlib绘图中文显示问题
- Python 迭代器工具包【推荐】
- Python 类与元类的深度挖掘 I【经验】
- Python 类与元类的深度挖掘 II【经验】
- Python进阶必读博文视频教程汇总
- python 发送邮件