最近有个项目欲安装MySQL-python/1.2.5一直失败。
环境:
win7
python3.6.2
报错信息如下:
Creating library build\temp.win32-3.6\Release\_mysql.cp36-win32.lib and o
bject build\temp.win32-3.6\Release\_mysql.cp36-win32.exp
mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol ___
iob_func
mysqlclient.lib(viosslfactories.obj) : error LNK2001: unresolved external sy
mbol ___iob_func
mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol
___iob_func
mysqlclient.lib(my_messnc.obj) : error LNK2001: unresolved external symbol _
__iob_func
mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol ___i
ob_func
mysqlclient.lib(my_thr_init.obj) : error LNK2001: unresolved external symbol
___iob_func
mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol ___
iob_func
mysqlclient.lib(default.obj) : error LNK2001: unresolved external symbol ___
iob_func
mysqlclient.lib(default.obj) : error LNK2001: unresolved external symbol _pr
intf
build\lib.win32-3.6\_mysql.cp36-win32.pyd : fatal error LNK1120: 2 unresolve
d externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\B
IN\\link.exe' failed with exit status 1120
----------------------------------------
Command "d:\programs\python36-32\python.exe -u -c "import setuptools, tokenize;_
_file__='C:\\Users\\code65\\AppData\\Local\\Temp\\pip-build-utscjthe\\mysql-pyth
on\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace(
'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\code65\AppData\Local\Temp\pip-784mj8vx-record\install-record.txt --sing
le-version-externally-managed --compile" failed with error code 1 in C:\Users\co
de65\AppData\Local\Temp\pip-build-utscjthe\mysql-python\
按好多网上解决办法都是失败的,原来由于 MySQLdb 模块还不支持 Python3.x,所以 Python3.x 如果想连接MySQL需要安装 pymysql 模块。
参考自http://www.cnblogs.com/hank-chen/p/6624299.html
D:\Python>pip install pymysql
Collecting pymysql
Downloading PyMySQL-0.7.11-py2.py3-none-any.whl (78kB)
38% |████████████▌ | 30kB 111kB/s eta 0:00:01
51% |████████████████▋ | 40kB 117kB/s eta 0:0
64% |████████████████████▊ | 51kB 127kB/s eta
77% |█████████████████████████ | 61kB 151kB/s
90% |█████████████████████████████ | 71kB 165
100% |████████████████████████████████| 81kB
179kB/s
Installing collected packages: pymysql
Successfully installed pymysql-0.7.11