“无法打开包含文件:'config-win.h':没有这样的文件或目录"在安装mysql-python时 [英] "Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python

查看:173
本文介绍了“无法打开包含文件:'config-win.h':没有这样的文件或目录"在安装mysql-python时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows上使用pip在virtualenv中安装mysql-python.最初,我在在这里报告时遇到了同样的错误,但是那里的答案也对我有用.现在出现以下错误:

I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error reported here, but the answer there worked for me too. Now I'm getting this following error:

_mysql.c(34) : Fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

如果我将(Win7)符号链接到我的常规(而不是virtualenv的)python的站点包/MySQLdb目录,则得到

If I symlink (Win7) to my regular (not the virtualenv's) python's site-packages/MySQLdb dir I get

Error loading MySQLdb module: No module named _mysql

我在这里不知所措.有指针吗?

I'm rather at a loss here. Any pointers?

推荐答案

针对MySQL 5.5和config-win.h的更新不可见问题

Update for mysql 5.5 and config-win.h not visible issue

在5.5 config-win中.实际上已移至Windows中的Connector单独文件夹.即类似:

In 5.5 config-win. has actually moved to Connector separate folder in windows. i.e. smth like:

C:\ Program Files \ MySQL \ Connector C 6.0.2 \ include

C:\Program Files\MySQL\Connector C 6.0.2\include

要解决该问题,不仅需要下载"dev bits"(实际上连接了 connector ),还需要修改mysqldb安装脚本以添加include文件夹.我已经做了一个快速的肮脏修复.

To overcome the problem one need not only to download "dev bits" (which actually connects the connector) but also to modify mysqldb install scripts to add the include folder. I've done a quick dirty fix as that.

site.cfg:

# Windows connector libs for MySQL.
connector = C:\Program Files\MySQL\Connector C 6.0.2

在setup_windows.py中找到该行

in setup_windows.py locate the line

include_dirs = [ os.path.join(mysql_root, r'include') ]:

并添加:

include_dirs = [ os.path.join(options['connector'], r'include') ]

之后.

丑陋,但要等到mysqldb作者更改行为后才能使用.

Ugly but works until mysqldb authors will change the behaviour.

几乎忘了提及.同样,需要为lib添加类似的附加条目:

Almost forgot to mention. In the same manner one needs to add similar additional entry for libs:

library_dirs = [ os.path.join(options['connector'], r'lib\opt') ]

即您的setup_windows.py看起来很像:

i.e. your setup_windows.py looks pretty much like:

...
library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
library_dirs = [ os.path.join(options['connector'], r'lib\opt') ]
libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
include_dirs = [ os.path.join(mysql_root, r'include') ]
include_dirs = [ os.path.join(options['connector'], r'include') ]
extra_compile_args = [ '/Zl' ]
...

这篇关于“无法打开包含文件:'config-win.h':没有这样的文件或目录"在安装mysql-python时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆