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

时间:2014-11-11 13:34:46

标签: python mysql mysql-python failed-installation

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

安装在我的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\1\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

9 个答案:

答案 0 :(得分:141)

用于64位窗口

答案 1 :(得分:41)

这对我不起作用:

function intercept(address) {
    try {
        Interceptor.attach(address, {
            onEnter: function(args) {
                console.log("onEnter", address);
            },
            onLeave: function(ignored) {}
        });
    } catch (e) {
        console.error(e);
    }
}
function Main() {
    var dlopen = new NativeFunction(Module.findExportByName(null, 'dlopen'), 'pointer', ['pointer', 'int']);
    var dlsym = new NativeFunction(Module.findExportByName(null, 'dlsym'), 'pointer', ['pointer', 'pointer']);
    Process.enumerateModulesSync().forEach(function(m) {
        if (m.name === "libfoo.so") {
            console.log("Module", JSON.stringify(m));
            var handle = dlopen(Memory.allocUtf8String(m.path), 1);
            var symb = Memory.allocUtf8String("foo");
            var exports = Module.enumerateExportsSync(m.name);
            console.log(JSON.stringify({
                handle: handle,
                symb: symb,
                dlsym: dlsym(handle, symb),
                exports: exports.map(function(ex){ return ex.address + ": " + ex.name })
            }, null, 2));
            // intercept all exports
            exports.forEach(function(ex){
                intercept(ex.address);
            });
            // explicit intercept foo by known offset
            intercept(m.base.add(0x22334)); // this outputs "Error: unable to intercept function at 0x86c96328; please file a bug"
        }
    });

    console.log("sleep..");
    Thread.sleep(1.5);
    console.log("invoke", Java.use('com.clazz.foo').signToken("A".repeat(32)));
}
Java.perform(Main);

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

pip install mysqlclient

一切顺利,不需要MS Visual C ++ 14构建工具和其他东西

注意:目前这不适用于Python3.7,我还必须降级到Python 3.6.5

答案 2 :(得分:8)

这对我有用:

false

这是对于窗口7中的python 3.x我不确定其他windows os版本

答案 3 :(得分:7)

您可以尝试...

   pip install mysqlclient==1.3.4

对我有用。

如果以上命令不起作用,请尝试...

 pip install --only-binary :all: mysqlclient

都为我工作。

答案 4 :(得分:5)

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

答案 5 :(得分:4)

您可以尝试安装另一个软件包:

pip install mysql-connector-python

此软件包对我来说效果很好,我没有安装任何问题。

答案 6 :(得分:1)

假设您要在Windows上安装软件包MySQL-python,可以尝试使用pip install的{​​{1}}命令。请参见下面的示例命令:

--global-option

对于此示例,我已在pip install MySQL-python ^ --force-reinstall --no-cache-dir ^ --global-option=build_ext ^ --global-option="-IC:\my\install\MySQL-x64\MySQL Connector C 6.0.2\include" ^ --global-option="-LC:\my\install\MySQL-x64\MySQL Connector C 6.0.2\lib\opt" ^ --verbose 的自定义位置完全安装了{strong> 64位版本的MySQL Connector C

顺便说一句,我注意到C:\my\install\MySQL-x64\MySQL Connector C 6.0.2\在默认情况下始终会查找目录pip install MySQL-python,即使您使用的是64位和/或已将驱动程序安装在其他位置。我在Python-2.7上进行了测试,我猜这是Python或MySQL-python的错误。

希望以上内容可能会有帮助。

答案 7 :(得分:0)

对我来说,当我选择正确的Python版本而不是计算机版本之一时,它可以工作。

我的是32位的,而我的计算机是64位的。那就是问题所在,并修复了该问题的32位版本。

确切地说,这是为我工作的那个: mysqlclient-1.3.13-cp37-cp37m-win32.whl

答案 8 :(得分:0)

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

贷记到“ https://mysql.wisborg.dk/2019/03/03/using-sqlalchemy-with-mysql-8/

然后我尝试:

pip安装轮

pip安装mysqlclient-1.4.2-cp37-cp37m-win_amd64.whl

python -m pip安装mysql-connector-python

python -m pip安装SQLAlchemy

它有效

谢谢

相关问题