mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory
问题描述:
pip instal mysql-python
出现如下错误:
installing collected packages: mysql-python
running setup.py install for mysql-python
......
_mysql.c(42) : fatal error c1083: cannot open include file: 'config-win.h': no such file or directory
error: command 'c:\\users\\administrator\\appdata\\local\\programs\\common\\microsoft\\visual c++ for python\\9.0\\vc\\bin\\cl.exe' failed with exit status 2
运行环境:
python 2.7.10
setuptools 41.0.1
pip 19.1
操作系统:windows7 64位
解决办法:
1) 安装mysql connector, 可根据系统版本选择安装32位或64位的, 下载地址:
2) 安装microsoft visual c++ compiler for python 2.7,要是安装mysql-python需要乃至vc的一些运行库,下载地址:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
(参考博客:)
按上面步骤安装好依赖相关软件后, 再次运行pip install mysql-python又遇到了以下问题
_mysql.c
_mysql.c(42) : fatal error c1083: cannot open include file: 'config-win.h': no s uch file or directory
error: command '"c:\users\fnngj\appdata\local\programs\common\microsoft\visual c ++ for python\9.0\vc\bin\amd64\cl.exe"' failed with exit status 2
按理说win7都出来这么多年了,python也更新的这么猛的语言,怎么链接mysql就不行了。
百度了半天,找到了以下答案:
----------------------------------------------
1)问题:_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 exitstatus 2
原因:原因是安装mysql的时候没有安装c语言库。
解决:重新运行mysql的安装程序,选择modify,把“c include files / lib files”勾选上,并安装。
---------------------------------------------
百度来百度去,就这么一个答案,都是复制粘贴的。害我反复把mysql装了几遍,跟本他妈的没找到“c include files / lib files” 选项在哪儿? 也许是mysql新版本没这选项了。
原来还是驱动问题,关人家mysql啥事儿!
安装:mysql-python-1.2.3.win-amd64-py2.7.exe 点击下载就可以了(或者百度csdn下载可以找到)
我的驱动是从这儿下的,不行!
https://pypi.python.org/pypi/mysql-python/
也用 pip 装了,不行!
c:\python27\scripts>pip install mysql-python
这pip居然检测不出我的系统版本。 还有为啥python官网搜索不到这个 64位的驱动,我也是醉了。
希望这个问题被百度收录,遇到这个问题的人,别在被上面的答案忽悠了,真不管人家mysql的事儿。
更新~~ 现在都2019年了,不用再纠结这个问题了,请使用 pymysql 驱动
https://github.com/pymysql/pymysql
但笔者却再次遇到了这个问题, 仔细看了下错误信息发现有如下提示:
c:\users\administrator\appdata\local\programs\common\microsoft\visual c++ for python\9.0\vc\bin\cl.exe /c /nologo /ox /md /w3 /gs- /dndebug -dversion_info=(1,2,5,'final',1) -d__version__=1.2.5 "-ic:\program files (x86)\mysql\mysql connector c 6.0.2\include" -ii:\python27\include -ii:\python27\pc /tc_mysql.c /fobuild\temp.win32-2.7\release\_mysql.obj /zl
之前安装的mysql connector是64位的, 安装到了c:\program files \mysql\mysql connector c 6.0.2目录,但从提示中看它要的是安装到c:\program files (x86)\mysql\mysql connector c 6.0.2,因此应该安装32位的mysql connector;
重新安装32位的mysql connector, 重新执行pip install mysql-python, 安装成功!
总结一下,造成上述的主要原因是: 系统中安装的python、pip 都是32位。
参考文章:
上一篇: 详解Vue的slot新用法
下一篇: python 之 面向对象 (异常处理)
推荐阅读
-
linux系统安装VMware(详细解决"Cannot open /dev/vmmon: No such file or directory"问题)
-
mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory,errorwhileloading_PHP教程
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory,errorwhileloading_PHP教程
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory - tianxintian22
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory,errorwhileloading
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory,errorwhileloading
-
linux下编译安装MariaDB 10.4.7,解决错误:cannot access ‘/auth_pam_tool_dir’: No such file or directory
-
mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory