window10 python3.5 安装mysql-python包

python2.7下安装mysql-python

http://blog.csdn.net/xxm524/article/details/48754139
一定要注意安装版本,由于版本错误,浪费好久好久的时间
错误:

_mysql.pyd : fatal error LNK1120: 56 unresolved externals
error: command '"C:Program Files (x86)Microsoft Visual Studio 9.0VCBINlink.
exe"' failed with exit status 1120

原因是VCForPython27.msi安装的32位,但是python是64位的。重新下载32位的python安装包,安装后再pip install mysql。正常。

windows系统python35 安装mysql-python

解决方案:

搜索半天,最终发现,python3不支持mysql-python了,多么痛的领悟啊!!!
安装第三方包pymysql。下载地址:https://pypi.python.org/pypi/PyMySQL#downloads
使用方法:

import pymysql as MySQLdb

django 中使用方法,在项目settings.py目录里的init.py加入

import pymysql
pymysql.install_as_MySQLdb()

解决过程:

  • 错误一:error: Unable to find vcvarsall.bat

**错误1:Microsoft Visual C++ 14.0 is required. **
从错误提示的url下载,下载后安装visualcppbuildtools_full

window10 python3.5 安装mysql-python包
Paste_Image.png

安装遇到错误:

window10 python3.5 安装mysql-python包
Paste_Image.png

百度搜索Microsoft Visual C++ 14.0 下载,在脚步之家下载的,约12M,安装成功。再次执行安装mysql-python,还是报错。

后又重新回到在线安装居然可以成功,这次选择的是自定义安装,勾选了win10 sdk和.net framework两个,安装空间居然需要8G,心疼。然后就是漫长的等待,第一次安装失败很有可能是网络原因。

window10 python3.5 安装mysql-python包
Paste_Image.png

安装完后,执行python setup.py install,报错:

C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:Program Files (x86)MySQLMySQL Connector C 6.0.2include" -Ic:usersmichaelzengappdatalocalprogramspythonpython36include -Ic:usersmichaelzengappdatalocalprogramspythonpython36include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" /Tc_mysql.c /Fobuildtemp.win-amd64-3.6Release_mysql.obj /Zl
    _mysql.c
    c:usersmichaelzengappdatalocalprogramspythonpython36includepyconfig.h(222): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

win10 sdks重装为win 8 sdks,再次执行,错误变为:

C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:Program Files (x86)MySQLMySQL Connector C 6.0.2include" -IC:UsersmichaelzengAppDataLocalProgramsPythonPython36include -IC:UsersmichaelzengAppDataLocalProgramsPythonPython36include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tc_mysql.c /Fobuildtemp.win-amd64-3.6Release_mysql.obj /Zl
_mysql.c
_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

安装mysql connector, 下载地址:https://dev.mysql.com/downloads/connector/python/
我的系统为64, 下载的是mysql-connector-python-2.1.5-py3.4-winx64,还是报错,后来注意到寻找的目录是Program Files (x86),又下了个32位的安装。错误过去了。但是又来新的错误:

LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup
buildlib.win-amd64-3.5_mysql.cp35-win_amd64.pyd : fatal error LNK1120: 56 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit status 1120

搜索半天,最终发现,python3不支持mysql-python了,多么痛的领悟啊!!!

安装第三方包pymysql。下载地址:https://pypi.python.org/pypi/PyMySQL#downloads
使用方法:

import pymysql as MySQLdb
       

本站文章如未特殊注明,均为原创,转载请注明出处: 未必平凡  本文链接地址: https://vv2014.com/709.html