mysql-python 安装错误:无法打开包含文件“config-win.h”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26866147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:05:40  来源:igfitidea点击:

mysql-python install error: Cannot open include file 'config-win.h'

pythonmysqlmysql-pythonfailed-installation

提问by Chris Meek

I am trying to run pip install mysql-python connectorbut it keeps giving me an error "Cannot open include file: 'config-win.h'".

我正在尝试运行,pip install mysql-python connector但它一直给我一个错误“无法打开包含文件:'config-win.h'”。

The installation works fine on my Mac and another Windows machine, but not this one. I have downloaded Visual Studio C++ and tried installing as both 32 bit and 64.

安装在我的 Mac 和另一台 Windows 机器上运行良好,但不是这个。我已经下载了 Visual Studio C++ 并尝试安装为 32 位和 64 位。

_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No s
uch file or directory

error: command 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\c
l.exe' failed with exit status 2

----------------------------------------
Cleaning up...
Command C:\Users\Admin1\Desktop\python\virtual\Scripts\python.exe -c "import set
uptools, tokenize;__file__='C:\Users\Admin1\Desktop\python\virtual\build\
MySQL-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).r
ead().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\admin
1\appdata\local\temp\pip-6pmwrd-record\install-record.txt --single-version-ext
ernally-managed --compile --install-headers C:\Users\Admin1\Desktop\python\virtu
al\include\site\python2.7 failed with error code 1 in C:\Users\Admin1\Desktop\py
thon\virtual\build\MySQL-python
Storing debug log for failure in C:\Users\Admin1\pip\pip.log

采纳答案by pokemon blue

for 64-bit windows

对于 64 位窗口

回答by kinsley kajiva

well this worked for me:

这对我有用:

pip install mysqlclient

this is for python 3.x in window 7 i am not sure about other windows os versions

这是针对窗口 7 中的 python 3.x 我不确定其他 Windows 操作系统版本

回答by applecrusher

I am using Windows 10 and overcame this issue by running the pip install mysql-connectorcommand in Windows PowerShell rather than the Command Prompt.

我正在使用 Windows 10 并通过pip install mysql-connector在 Windows PowerShell 中运行命令而不是命令提示符来克服这个问题。

回答by kaya

This didnt work for me:

这对我不起作用:

pip install mysqlclient

so i found this after a while on stackoverflow:

所以我在stackoverflow上发现了一段时间:

pip install --only-binary :all: mysqlclient

and it went all through, no need for MS Visual C++ 14 Build tools and stuff

一切都过去了,不需要 MS Visual C++ 14 构建工具和东西

Note: for now this doesnt work with Python3.7, i also had to downgrade to Python 3.6.5

注意:现在这不适用于 Python3.7,我也不得不降级到 Python 3.6.5

回答by Javed

You can try...

你可以试试...

   pip install mysqlclient==1.3.4

It worked for me.

它对我有用。

If the above command doesn't work try this...

如果上面的命令不起作用试试这个...

 pip install --only-binary :all: mysqlclient

both worked for me.

两者都为我工作。

回答by g__n

you can try to install another package:

你可以尝试安装另一个包:

pip install mysql-connector-python

This package worked fine for me and I got no issues to install.

这个包对我来说很好用,我没有安装问题。

回答by Fouad Boukredine

For me, it worked when I selected the correct bit of my Python version, NOT the one of my computer version.

对我来说,当我选择了正确的 Python 版本而不是我的计算机版本时,它就起作用了。

Mine is 32bit, and my computer is 64bit. That was the problem and the 32bit version of fixed it.

我的是32位的,我的电脑是64位的。这就是问题所在,32 位版本的修复了它。

to be exact, here is the one that worked for me: mysqlclient-1.3.13-cp37-cp37m-win32.whl

确切地说,这是对我有用的:mysqlclient-1.3.13-cp37-cp37m-win32.whl

回答by sxzhangzsx

For mysql8and python 3.7on windows, I find previous solutions seems not work for me.

对于Windowsmysql8python 3.7Windows,我发现以前的解决方案似乎对我不起作用。

Here is what worked for me:

这是对我有用的:

pip install wheel

pip install mysqlclient-1.4.2-cp37-cp37m-win_amd64.whl

python -m pip install mysql-connector-python

python -m pip install SQLAlchemy

Reference: https://mysql.wisborg.dk/2019/03/03/using-sqlalchemy-with-mysql-8/

参考:https: //mysql.wisborg.dk/2019/03/03/using-sqlalchemy-with-mysql-8/