繁体   English   中英

在 Windows 上 PIP 安装 MySQL-python 在 Python 64 位中失败,但如果使用 32 位则成功

[英]PIP install MySQL-python on Windows fails in Python 64bit but succeeds if use 32bit

我正在 Windows 上使用 Python 2.7 做一些遗留工作,如果使用 Python-2.7 32 位的虚拟环境,并调用“pip install --force-reinstall --no-cache-dir MySQL-python”它完成所有好的。

但是,如果在 64 位中使用 Python-2.7,则会失败并显示以下错误。 我注意到消息“-IC:\\Program Files (x86)\\MySQL\\MySQL Connector C 6.0.2\\include”,这意味着编译器试图包含 32 位文件,尽管这是一个 64 位 Python 环境。

除了非官方的轮子之外,您能否给我一些有关如何修复此错误并实际安装此 Python 包的指示?

出于验证的目的,我确实需要使用 --no-cache-dir 选项进行全新安装。 感谢您的帮助。

错误信息:

(venv) D:\work\test_x64>where python
D:\work\test_x64\venv\Scripts\python.exe

(venv) D:\work\test_x64>python
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

(venv) D:\work\test_x64>pip install MySQL-python
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip (108 kB)
Building wheels for collected packages: MySQL-python
  Building wheel for MySQL-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\work\test_x64\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\setup.py'"'"'; __file__='"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'c:\users\admini~1\appdata\local\temp\1\pip-wheel-_dphfq'
       cwd: c:\users\admini~1\appdata\local\temp\1\pip-install-q_zmcv\mysql-python\
  Complete output (103 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-2.7
  copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
  creating build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
  copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
  creating build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\constants
  running build_ext
  building '_mysql' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\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" -ID:\work\test_x64\venv\include -ID:\work\test_x64\venv\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
  _mysql.c
  C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(203) : warning C4005: 'SIZEOF_OFF_T' : macro redefinition
          d:\work\test_x64\venv\include\pyconfig.h(347) : see previous definition of 'SIZEOF_OFF_T'
  C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(301) : warning C4005: 'HAVE_STDDEF_H' : macro redefinition
          d:\work\test_x64\venv\include\pyconfig.h(687) : see previous definition of 'HAVE_STDDEF_H'
  _mysql.c(287) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(317) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(470) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(1168) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(1274) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(1466) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1468) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1504) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1506) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1532) : warning C4018: '<' : signed/unsigned mismatch
  _mysql.c(2302) : warning C4244: 'function' : conversion from '__int64' to 'long', possible loss of data
  C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" /LIBPATH:D:\work\test_x64\venv\libs /LIBPATH:D:\work\test_x64\venv\PCbuild\amd64 /LIBPATH:D:\work\test_x64\venv\PC\VS9.0\amd64 kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:init_mysql build\temp.win-amd64-2.7\Release\_mysql.obj /OUT:build\lib.win-amd64-2.7\_mysql.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\_mysql.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\_mysql.pyd.manifest
  _mysql.obj : warning LNK4197: export 'init_mysql' specified multiple times; using first specification
     Creating library build\temp.win-amd64-2.7\Release\_mysql.lib and object build\temp.win-amd64-2.7\Release\_mysql.exp
  _mysql.obj : error LNK2019: unresolved external symbol mysql_error referenced in function _mysql_Exception
  _mysql.obj : error LNK2019: unresolved external symbol mysql_errno referenced in function _mysql_Exception
  _mysql.obj : error LNK2019: unresolved external symbol mysql_server_init referenced in function _mysql_server_init
  _mysql.obj : error LNK2019: unresolved external symbol mysql_server_end referenced in function _mysql_server_end
  _mysql.obj : error LNK2019: unresolved external symbol mysql_thread_safe referenced in function _mysql_thread_safe
  _mysql.obj : error LNK2019: unresolved external symbol mysql_fetch_fields referenced in function _mysql_ResultObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_num_fields referenced in function _mysql_ResultObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_field_count referenced in function _mysql_ResultObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_store_result referenced in function _mysql_ResultObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_use_result referenced in function _mysql_ResultObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function _mysql_ConnectionObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_ssl_set referenced in function _mysql_ConnectionObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_options referenced in function _mysql_ConnectionObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_init referenced in function _mysql_ConnectionObject_Initialize
  _mysql.obj : error LNK2019: unresolved external symbol mysql_close referenced in function _mysql_ConnectionObject_close
  _mysql.obj : error LNK2019: unresolved external symbol mysql_affected_rows referenced in function _mysql_ConnectionObject_affected_rows
  _mysql.obj : error LNK2019: unresolved external symbol mysql_debug referenced in function _mysql_debug
  _mysql.obj : error LNK2019: unresolved external symbol mysql_dump_debug_info referenced in function _mysql_ConnectionObject_dump_debug_info
  _mysql.obj : error LNK2019: unresolved external symbol mysql_autocommit referenced in function _mysql_ConnectionObject_autocommit
  _mysql.obj : error LNK2019: unresolved external symbol mysql_commit referenced in function _mysql_ConnectionObject_commit
  _mysql.obj : error LNK2019: unresolved external symbol mysql_rollback referenced in function _mysql_ConnectionObject_rollback
  _mysql.obj : error LNK2019: unresolved external symbol mysql_next_result referenced in function _mysql_ConnectionObject_next_result
  _mysql.obj : error LNK2019: unresolved external symbol mysql_set_server_option referenced in function _mysql_ConnectionObject_set_server_option
  _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
  error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120
  ----------------------------------------
  ERROR: Failed building wheel for MySQL-python
  Running setup.py clean for MySQL-python
Failed to build MySQL-python
DEPRECATION: Could not build wheels for MySQL-python which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
Installing collected packages: MySQL-python
    Running setup.py install for MySQL-python ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\work\test_x64\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\setup.py'"'"'; __file__='"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\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\admini~1\appdata\local\temp\1\pip-record-ae_5vh\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\work\test_x64\venv\include\site\python2.7\MySQL-python'
         cwd: c:\users\admini~1\appdata\local\temp\1\pip-install-q_zmcv\mysql-python\
    Complete output (103 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
    creating build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\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" -ID:\work\test_x64\venv\include -ID:\work\test_x64\venv\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
    _mysql.c
    C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(203) : warning C4005: 'SIZEOF_OFF_T' : macro redefinition
            d:\work\test_x64\venv\include\pyconfig.h(347) : see previous definition of 'SIZEOF_OFF_T'
    C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(301) : warning C4005: 'HAVE_STDDEF_H' : macro redefinition
            d:\work\test_x64\venv\include\pyconfig.h(687) : see previous definition of 'HAVE_STDDEF_H'
    _mysql.c(287) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(317) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(470) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(1168) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(1274) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(1466) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1468) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1504) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1506) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1532) : warning C4018: '<' : signed/unsigned mismatch
    _mysql.c(2302) : warning C4244: 'function' : conversion from '__int64' to 'long', possible loss of data
    C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" /LIBPATH:D:\work\test_x64\venv\libs /LIBPATH:D:\work\test_x64\venv\PCbuild\amd64 /LIBPATH:D:\work\test_x64\venv\PC\VS9.0\amd64 kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:init_mysql build\temp.win-amd64-2.7\Release\_mysql.obj /OUT:build\lib.win-amd64-2.7\_mysql.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\_mysql.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\_mysql.pyd.manifest
    _mysql.obj : warning LNK4197: export 'init_mysql' specified multiple times; using first specification
       Creating library build\temp.win-amd64-2.7\Release\_mysql.lib and object build\temp.win-amd64-2.7\Release\_mysql.exp
    _mysql.obj : error LNK2019: unresolved external symbol mysql_error referenced in function _mysql_Exception
    _mysql.obj : error LNK2019: unresolved external symbol mysql_errno referenced in function _mysql_Exception
    _mysql.obj : error LNK2019: unresolved external symbol mysql_server_init referenced in function _mysql_server_init
    _mysql.obj : error LNK2019: unresolved external symbol mysql_server_end referenced in function _mysql_server_end
    _mysql.obj : error LNK2019: unresolved external symbol mysql_thread_safe referenced in function _mysql_thread_safe
    _mysql.obj : error LNK2019: unresolved external symbol mysql_fetch_fields referenced in function _mysql_ResultObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_num_fields referenced in function _mysql_ResultObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_field_count referenced in function _mysql_ResultObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_store_result referenced in function _mysql_ResultObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_use_result referenced in function _mysql_ResultObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function _mysql_ConnectionObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_ssl_set referenced in function _mysql_ConnectionObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_options referenced in function _mysql_ConnectionObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_init referenced in function _mysql_ConnectionObject_Initialize
    _mysql.obj : error LNK2019: unresolved external symbol mysql_close referenced in function _mysql_ConnectionObject_close
    _mysql.obj : error LNK2019: unresolved external symbol mysql_affected_rows referenced in function _mysql_ConnectionObject_affected_rows
    _mysql.obj : error LNK2019: unresolved external symbol mysql_debug referenced in function _mysql_debug
    _mysql.obj : error LNK2019: unresolved external symbol mysql_dump_debug_info referenced in function _mysql_ConnectionObject_dump_debug_info
    _mysql.obj : error LNK2019: unresolved external symbol mysql_autocommit referenced in function _mysql_ConnectionObject_autocommit
    _mysql.obj : error LNK2019: unresolved external symbol mysql_commit referenced in function _mysql_ConnectionObject_commit
    _mysql.obj : error LNK2019: unresolved external symbol mysql_rollback referenced in function _mysql_ConnectionObject_rollback
    _mysql.obj : error LNK2019: unresolved external symbol mysql_next_result referenced in function _mysql_ConnectionObject_next_result
    _mysql.obj : error LNK2019: unresolved external symbol mysql_set_server_option referenced in function _mysql_ConnectionObject_set_server_option
    _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
    error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\work\test_x64\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\setup.py'"'"'; __file__='"'"'c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q_zmcv\\mysql-python\\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\admini~1\appdata\local\temp\1\pip-record-ae_5vh\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\work\test_x64\venv\include\site\python2.7\MySQL-python' Check the logs for full command output.
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'D:\work\test_x64\venv\Scripts\python.exe -m pip install --upgrade pip' command.

(venv) D:\work\test_x64>


尝试安装这些,

pip install pymysql

或者

pip install mysql-connector

或者

pip install mysql-connector-python

或者你可以从 lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 安装轮子

您不需要安装 Visual Studio 构建工具。

作为一种解决方法,我通过使用--global-option调用pip install命令来指定包含和 lib 文件的路径来解决它。 请参阅下面的示例命令:

pip install MySQL-python ^
 --global-option=build_ext ^
 --global-option="-IC:\my\install\MySQL-x64\MySQL Connector C 6.0.2\include" ^
 --global-option="-LC:\my\install\MySQL-x64\MySQL Connector C 6.0.2\lib\opt"

请注意,我已经在上面示例中给出的自定义位置完全安装了 64 位版本的MySQL-x64\\MySQL Connector C 6.0.2 我的另一个问题的自我发布答案中查看更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM