Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PIP在Windows上安装MySQL python在python 64位时失败,但在使用32位时成功_Python_Windows_Python 2.7_Mysql Python - Fatal编程技术网

PIP在Windows上安装MySQL python在python 64位时失败,但在使用32位时成功

PIP在Windows上安装MySQL python在python 64位时失败,但在使用32位时成功,python,windows,python-2.7,mysql-python,Python,Windows,Python 2.7,Mysql Python,我正在Windows上使用Python2.7做一些遗留工作,如果使用一个32位的Python-2.7虚拟环境,并调用“pip安装——强制重新安装——无缓存目录MySQL Python”,就完成了所有工作 但是,如果使用64位的Python-2.7,它将失败,并在下面附加错误。我注意到消息“-IC:\Program Files(x86)\MySQL\MySQL Connector C 6.0.2\include”,这意味着编译器试图包含32位文件,尽管这是一个64位Python环境 除此之外,你能

我正在Windows上使用Python2.7做一些遗留工作,如果使用一个32位的Python-2.7虚拟环境,并调用“pip安装——强制重新安装——无缓存目录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>


(venv)D:\work\test\u x64>其中python
D:\work\test\u x64\venv\Scripts\python.exe
(venv)D:\work\test\u x64>python
win32上的Python 2.7.18(v2.7.18:8d21aa21f2,2020年4月20日,13:25:05)[MSC v.1500 64位(AMD64)]
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>退出
(venv)D:\work\test\u x64>pip安装MySQL python
弃用:Python 2.7在2020年1月1日结束了它的生命。请升级Python,因为不再维护Python 2.7。PIP21.0将在2021年1月放弃对Python2.7的支持。有关pip中Python 2支持的更多详细信息,请访问https://pip.pypa.io/en/latest/development/release-process/#python-2-支持
收集MySQL-python
使用缓存的MySQL-python-1.2.5.zip(108 kB)
为收集的包构建控制盘:MySQL-python
正在为MySQL python构建控制盘(setup.py)。。。错误
错误:命令出错,退出状态为1:
命令:“D:\work\test\u 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”__文件“''''c:\\users\\admini~1\\appdata\\local\\temp\\1\\pip-install-q\u zmcv\\mysql python\\setup.py''”;f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,“'exec'”)'bdist\u wheel-d'c:\users\admini~1\appdata\local\temp\1\pip wheel-\u dphfq'
cwd:c:\users\admini~1\appdata\local\temp\1\pip-install-q\u zmcv\mysql-python\
完整输出(103行):
运转的车轮
运行构建
运行build\u py
创建构建
正在创建build\lib.win-amd64-2.7
正在复制\u mysql\u exceptions.py->build\lib.win-amd64-2.7
正在创建build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\\ uuuu init\ uuuu.py->build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\converters.py->build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\connections.py->build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\cursors.py->build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\release.py->build\lib.win-amd64-2.7\MySQLdb
正在复制MySQLdb\times.py->build\lib.win-amd64-2.7\MySQLdb
正在创建build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\\uuuu init\uuuu.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\CR.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\FIELD_TYPE.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\ER.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\FLAG.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\REFRESH.py->build\lib.win-amd64-2.7\MySQLdb\constants
正在复制MySQLdb\constants\CLIENT.py->build\lib.win-amd64-2.7\MySQLdb\constants
运行build_ext
正在生成“\u mysql”扩展
正在创建build\temp.win-amd64-2.7
创建build\temp.win-amd64-2.7\Release
C:\Pyth\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\/\Ma\[4] \[/EXE/C/Nexo/ox/M3/G3/DNDebug——(1,2,5,‘最后’,1)-DyVeluon C++=1.2.5“-IC:\程序文件(x86)\ MySQL \ MySQL连接器C60.2\\”,请参见“9”,“-ID:\work\test\u x64\venv\include-ID:\work\test\u x64\venv\PC/Tc\u mysql.c/Fobuild\temp.win-amd64-2.7\Release\\u mysql.obj/Zl
_mysql.c
C:\Program Files(x86)\MySQL\MySQL Connector C 6.0.2\include\config win.h(203):警告C4005:“SIZEOF\u OFF\u T”:宏重新定义
d:\work\test\u x64\venv\include\pyconfig.h(347):请参阅前面对“SIZEOF\u OFF\T”的定义
C:\Program Files(x86)\MySQL\MySQL Connector C 6.0.2\include\config win.h(301):警告C4005:“HAVE_STDDEF_h”:宏重新定义
d:\work\test\u x64\venv\include\pyconfig.h(687):请参阅“HAVE\u STDDEF\u h”的先前定义
_c(287):警告C4244:“=”:从“Py_ssize_t”转换为“int”,可能会丢失数据
_c(317):警告C4244:“=”:从“Py_ssize_t”转换为“int”,可能会丢失数据
_c(470):警告C4244:“正在初始化”:从'Py_ssize_t'转换为'int',可能会丢失数据
_c(1168):警告C4244:“=”:从“Py_ssize_t”转换为“int”,可能会丢失数据
_c(1274):警告C4244:“=”:从“Py_ssize_t”转换为“int”,可能会丢失数据
_c(1466):警告C4267:“=”:从“size_t”转换为“int”,可能会丢失数据
_c(1468):警告C4267:“=”:从“size\u t”转换为“int”,可能会丢失数据
_c(1504):警告C4267:“=”:从“size_t”转换为“int”,可能会丢失数据
_c(1506):警告C4267:“=”:从“size_t”转换为“int”,可能会丢失数据
_c(1532):警告C4018:“尝试安装这些

pip install pymysql

或者可以从lfd.uci.edu/~gohlke/pythonlibs/#mysql-python安装控制盘


您不需要安装visual studio生成工具。

作为一种解决方法,我通过使用
--全局选项
调用
pip install
命令来指定include和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"
注意,我已经完全明白了
pip install mysql-connector-python
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"