我在窗口 10 64bit 上使用 pip install flask-mysqldb 时遇到问题,出现错误
Posted
技术标签:
【中文标题】我在窗口 10 64bit 上使用 pip install flask-mysqldb 时遇到问题,出现错误【英文标题】:I Have problem for using pip install flask-mysqldb on window 10 64bit , I got an Error 【发布时间】:2020-09-24 03:25:00 【问题描述】:我试图在窗口 10 64 位上安装 mysql,我有 python3.7.4 版本当我托盘 pip install mysql 我得到错误 MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql. h':没有这样的文件或目录,所以我有 Python版本:3.7.4 操作系统:Windows 10 点子版本:20.1
无法 pip install flask-mysqldb
这是我遇到的错误的摘要......
C:\Users\Omar Faaruuq>pip install mysql
Collecting mysql
Downloading mysql-0.0.2.tar.gz (1.9 kB)
Collecting mysqlclient
Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Building wheels for collected packages: mysql, mysqlclient
Building wheel for mysql (setup.py) ... done
Created wheel for mysql: filename=mysql-0.0.2-py3-none-any.whl size=1252 sha256=fd9a7bdc9cfebc286a66598c32d555b935dfa38a3e1b687096dfa22bf50100d1
Stored in directory: c:\users\omar faaruuq\appdata\local\pip\cache\wheels\f6\60\6d\b1cf0653d003ddb0be2985a4d5f2c6f977d91f0862df094de8
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\omar faaruuq\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\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\OMARFA~1\AppData\Local\Temp\pip-wheel-usgog472'
cwd: C:\Users\OMARFA~1\AppData\Local\Temp\pip-install-m0eys0mm\mysqlclient\
Complete output (30 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.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\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building 'MySQLdb._mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\MySQLdb
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" "-Ic:\users\omar faaruuq\appdata\local\programs\python\python37-32\include" "-Ic:\users\omar faaruuq\appdata\local\programs\python\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
_mysql.c
MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Successfully built mysql
Failed to build mysqlclient
Installing collected packages: mysqlclient, mysql
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\omar faaruuq\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\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\OMARFA~1\AppData\Local\Temp\pip-record-cc7qd2yb\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\omar faaruuq\appdata\local\programs\python\python37-32\Include\mysqlclient'
cwd: C:\Users\OMARFA~1\AppData\Local\Temp\pip-install-m0eys0mm\mysqlclient\
Complete output (30 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.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\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building 'MySQLdb._mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\MySQLdb
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" "-Ic:\users\omar faaruuq\appdata\local\programs\python\python37-32\include" "-Ic:\users\omar faaruuq\appdata\local\programs\python\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
_mysql.c
MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\omar faaruuq\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\OMARFA~1\\AppData\\Local\\Temp\\pip-install-m0eys0mm\\mysqlclient\\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\OMARFA~1\AppData\Local\Temp\pip-record-cc7qd2yb\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\omar faaruuq\appdata\local\programs\python\python37-32\Include\mysqlclient' Check the logs for full command output.
【问题讨论】:
【参考方案1】:您必须安装 Visual Studio Build Tools 和 MySQL connector
或
通过downloading它通过非官方***安装mysqlclient并安装
pip install mysqlclient‑1.4.6‑cp37‑cp37m‑win_amd64.whl
【讨论】:
以上是关于我在窗口 10 64bit 上使用 pip install flask-mysqldb 时遇到问题,出现错误的主要内容,如果未能解决你的问题,请参考以下文章
在 Ubuntu 15.10 上使用 pip 安装模块时出错
数据提示(在调试模式下将鼠标悬停在变量上)在 Visual Studio 2012 / Win 7 64bit 中不起作用