Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
420 views
in Technique[技术] by (71.8m points)

python - pip install mysqlclient returns "fatal error C1083: Cannot open file: 'mysql.h': No such file or directory

Here is this issue: I attempt to install mysqlclient like so

C:Usersamccommon349>pip install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1
cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command c:usersamccommon349appdatalocalprogramspythonpython36python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\AMCCOM~1\AppData\Local\Temp\pip-install-qcgo48hf\mysqlclient\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersAMCCOM~1AppDataLocalTemppip-record-q4yoftj8install-record.txt --single-version-externally-managed --compile:

c:usersamccommon349appdatalocalprogramspythonpython36libdistutilsdist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating buildlib.win-amd64-3.6
copying _mysql_exceptions.py -> buildlib.win-amd64-3.6
creating buildlib.win-amd64-3.6MySQLdb
copying MySQLdb\__init__.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdbcompat.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdbconnections.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdbconverters.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdbcursors.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdb
elease.py -> buildlib.win-amd64-3.6MySQLdb
copying MySQLdbimes.py -> buildlib.win-amd64-3.6MySQLdb
creating buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstants\__init__.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win-amd64-3.6MySQLdbconstants
copying MySQLdbconstantsREFRESH.py -> buildlib.win-amd64-3.6MySQLdbconstants
running build_ext
building '_mysql' extension
creating buildemp.win-amd64-3.6
creating buildemp.win-amd64-3.6Release
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.14.26428inHostX86x64cl.exe /c/nologo/Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1include" -Ic:usersamccommon349appdatalocalprogramspythonpython36include -Ic:usersamccommon349appdatalocalprogramspythonpython36include "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.14.26428include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0um" "-IC:ProgramFiles (x86)Windows Kits10include10.0.17134.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0cppwinrt" /Tc_mysql.c /Fobuildemp.win-amd64-3.6Release\_mysql.obj /Zl _mysql.c
_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\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe' failed with exit status 2

I made sure I had all of the files needed from visual studios build tools, I downloaded the mysql-python connector, and updated my pip and setup tools. I am a complete beginner to this and would appreciate any input as to how to go about fixing this error.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can download unofficial windows binaries for your python version using https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient. Then install it using pip. This way you'll be able to avoid the hassle of dealing with visual studio build tools.

Just download the mysqlclient.whl file most applicable to you. I think in your case it'll be

mysqlclient?1.3.13?cp36?cp36m?win_amd64.whl

and run

pip install "path to the downloaded .whl file"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...