在为烧瓶安装mysql-python时出错

时间:2020-04-29 19:35:08

标签: python mysql python-3.x pip mysql-python

我正在使用python v3.7。我想为烧瓶应用程序安装mysql-python。我得到ModuleNotFoundError: No module named 'MySQLdb',并在互联网上搜索,发现可以通过安装 mysql-python mysqlclient 来解决。 但是,当我尝试使用命令pip install mysql-python安装 mysql-python 时出现以下错误。请帮助解决它们。谢谢。

    Defaulting to user installation because normal site-packages is not writeable
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): started
  Building wheel for mysql-python (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files (x86)\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\mysql-python\\setup.py'"'"'; __file__='"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\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\Anshu\AppData\Local\Temp\pip-wheel-rqv0mwcp'
       cwd: C:\Users\Anshu\AppData\Local\Temp\pip-install-hx2vj4vu\mysql-python\
  Complete output (29 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.7
  copying _mysql_exceptions.py -> build\lib.win32-3.7
  creating build\lib.win32-3.7\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
  creating build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
  running build_ext
  building '_mysql' extension
  creating build\temp.win32-3.7
  creating build\temp.win32-3.7\Release
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" "-Ic:\program files (x86)\python37-32\include" "-Ic:\program files (x86)\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl
  _mysql.c
  c:\program files (x86)\python37-32\include\pyconfig.h(203): 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\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for mysql-python
  Running setup.py clean for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
    Running setup.py install for mysql-python: started
    Running setup.py install for mysql-python: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: 'c:\program files (x86)\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\mysql-python\\setup.py'"'"'; __file__='"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\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\Anshu\AppData\Local\Temp\pip-record-q9lznfeo\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\Anshu\AppData\Roaming\Python\Python37\Include\mysql-python'
         cwd: C:\Users\Anshu\AppData\Local\Temp\pip-install-hx2vj4vu\mysql-python\
    Complete output (29 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying _mysql_exceptions.py -> build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" "-Ic:\program files (x86)\python37-32\include" "-Ic:\program files (x86)\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl
    _mysql.c
    c:\program files (x86)\python37-32\include\pyconfig.h(203): 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\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\program files (x86)\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\mysql-python\\setup.py'"'"'; __file__='"'"'C:\\Users\\Anshu\\AppData\\Local\\Temp\\pip-install-hx2vj4vu\\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\Anshu\AppData\Local\Temp\pip-record-q9lznfeo\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\Anshu\AppData\Roaming\Python\Python37\Include\mysql-python' Check the logs for full command output.

1 个答案:

答案 0 :(得分:0)

有时,人们在使用可视C ++工具时会遇到相同的错误,再次启动安装程序,并根据您的操作系统选择Windows 8.1 / 10 SDK。这将修复basestd.h错误。

如果仍然无法正常运行,请尝试从以下位置启动生成工具:C:\ Program Files(x86)\ Microsoft Visual C ++生成工具。

另一种选择是,只需安装anaconda 2或3(如果您也不想出现内存错误,则安装64位)。它包含所有预先构建的重要软件包:sklearn,matplotlib,scipy,numpy,pandas甚至是Web开发框架(例如flask)。

我希望这对<3

有帮助
相关问题