Windows下mysql-python安装

最近接手一个同事留下来的后台网站,后端使用Webpy+mysql弄的,于是要安装一下webpy、mysql等等。我的系统是Windows 10 x64。安装完以后运行一下webpy,报错如下:

Traceback (most recent call last):
  File "D:\svn\testmanager\webtest\web\db.py", line 1184, in database
    return _databases[dbn](**params)
  File "D:\svn\testmanager\webtest\web\db.py", line 987, in __init__
    import MySQLdb as db
ImportError: No module named MySQLdb

发现少了一个mysql-python库的安装,执行pip install mysql-python,结果报错如下:

......
_mysql.obj : error LNK2019: unresolved external symbol mysql_sqlstate referenced in function _mysql_ConnectionObject_sqlstate
_mysql.obj : error LNK2019: unresolved external symbol mysql_warning_count referenced in function _mysql_ConnectionObject_warning_count
_mysql.obj : error LNK2019: unresolved external symbol mysql_escape_string referenced in function _mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol mysql_real_escape_string referenced in function _mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol mysql_fetch_lengths referenced in function _mysql_row_to_tuple
_mysql.obj : error LNK2019: unresolved external symbol __imp_strncat referenced in function _mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol __imp_strncpy referenced in function _mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol memset referenced in function _mysql_row_to_dict_old
_mysql.obj : error LNK2019: unresolved external symbol mysql_fetch_row referenced in function _mysql__fetch_row
_mysql.obj : error LNK2019: unresolved external symbol mysql_num_rows referenced in function _mysql_ResultObject_fetch_row
_mysql.obj : error LNK2019: unresolved external symbol mysql_change_user referenced in function _mysql_ConnectionObject_change_user
_mysql.obj : error LNK2019: unresolved external symbol mysql_character_set_name referenced in function _mysql_ConnectionObject_character_set_name
_mysql.obj : error LNK2019: unresolved external symbol mysql_set_character_set referenced in function _mysql_ConnectionObject_set_character_set
_mysql.obj : error LNK2019: unresolved external symbol mysql_get_character_set_info referenced in function _mysql_ConnectionObject_get_character_set_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_get_client_info referenced in function _mysql_get_client_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_get_host_info referenced in function _mysql_ConnectionObject_get_host_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_get_proto_info referenced in function _mysql_ConnectionObject_get_proto_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_get_server_info referenced in function _mysql_ConnectionObject_get_server_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_info referenced in function _mysql_ConnectionObject_info
_mysql.obj : error LNK2019: unresolved external symbol mysql_insert_id referenced in function _mysql_ConnectionObject_insert_id
_mysql.obj : error LNK2019: unresolved external symbol mysql_kill referenced in function _mysql_ConnectionObject_kill
_mysql.obj : error LNK2019: unresolved external symbol mysql_ping referenced in function _mysql_ConnectionObject_ping
_mysql.obj : error LNK2019: unresolved external symbol mysql_real_query referenced in function _mysql_ConnectionObject_query
_mysql.obj : error LNK2019: unresolved external symbol mysql_select_db referenced in function _mysql_ConnectionObject_select_db
_mysql.obj : error LNK2019: unresolved external symbol mysql_shutdown referenced in function _mysql_ConnectionObject_shutdown
_mysql.obj : error LNK2019: unresolved external symbol mysql_stat referenced in function _mysql_ConnectionObject_stat
_mysql.obj : error LNK2019: unresolved external symbol mysql_thread_id referenced in function _mysql_ConnectionObject_thread_id
_mysql.obj : error LNK2019: unresolved external symbol __imp_sprintf referenced in function _mysql_ConnectionObject_repr
_mysql.obj : error LNK2019: unresolved external symbol mysql_data_seek referenced in function _mysql_ResultObject_data_seek
_mysql.obj : error LNK2019: unresolved external symbol mysql_row_seek referenced in function _mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol mysql_row_tell referenced in function _mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol mysql_free_result referenced in function _mysql_ResultObject_dealloc
LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup
build\lib.win-amd64-2.7\_mysql.pyd : fatal error LNK1120: 56 unresolved externals
......

一番查看,发现安装MySQL的时候,默认安装的是MySQL Connector C 6.1 32位。

所以就去https://dev.mysql.com/downloads/file/?id=378025 下载了个64位的6.0.2版本,下载了我需要的MySQL-python-1.2.5

把原来site.cfg中的connector路径改为了我新下载的64位6.0.2的路径

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

在下载的mysql-python-1.2.5目录下执行

python setup.py install

这次就安装成功啦

你可能感兴趣的:(database)