Python 2.7 64 位错误地将 32 位 (x86) 引用为包含文件
我正在使用 64 位 Python 2.7.18 做一些遗留工作.当 PIP 调用编译器(Python 的 VC)时,它错误地引用 32 位 (x86) 源寻找包含文件,例如 "-IC:Program Files (x86)MySQLMySQL Connector C 6.0.2include"
.
I'm doing some legacy work with Python 2.7.18 in 64 bit. When PIP calling the compiler (VC for Python), it erroneously refer to 32-bit (x86) sources looking for include files, for example "-IC:Program Files (x86)MySQLMySQL Connector C 6.0.2include"
.
对于 32 位,一切正常;对于 64 位,预编译的wheel 文件是我现在不想使用的替代方法.
For 32-bit everything works all OK; for 64-bit the pre-compiled wheel file is an alternative that I prefer not to use for now.
我想知道我是否错过了将 python 及其编译器指向 64 位而不是 x86 的任何设置?
I'm wondering did I miss any setting pointing python and its compiler to 64-bit instead of x86?
或者,至少我想知道为什么 64 位不是指 64 位源的正确路径.任何指针将不胜感激.
Or, at lease I want to know why 64-bit doesn't refer to the correct path for 64-bit sources. Any pointers will be highly appreciated.
调用 Visual C++ 编译器的示例屏幕输出:
...
creating build emp.win-amd64-2.7
creating build emp.win-amd64-2.7Release
C:UsersAdministratorAppDataLocalProgramsCommonMicrosoft
Visual C++ for Python9.0VCBinamd64cl.exe /c /nologo /Ox /MD /W3 /GS-
/DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:Program Files
(x86)MySQLMySQL Connector C 6.0.2include" -IC:my est-pipvenv-x64include -
IC:my est-pipvenv-x64PC /Tc_mysql.c /Fobuild emp.win-amd64-
2.7Release\_mysql.obj /Zl
...
作为一种解决方法,我通过调用带有 --global-option
的 pip install
命令来解决它指定包含和 lib 文件的路径.请参阅下面的示例命令:
As a workaround, I resolved it by calling pip install
command with --global-option
to specify path of include and lib files. See the example command below:
pip install MySQL-python ^
--force-reinstall --no-cache-dir ^
--global-option=build_ext ^
--global-option="-IC:myinstallMySQL-x64MySQL Connector C 6.0.2include" ^
--global-option="-LC:myinstallMySQL-x64MySQL Connector C 6.0.2libopt" ^
--verbose
在这个例子中,我在C:myinstallMySQL-x64的自定义位置完全安装了64位版本的
.MySQL Connector C
MySQL 连接器 C 6.0.2
In this example, I have fully installed 64-bit version of MySQL Connector C
in customized location of C:myinstallMySQL-x64MySQL Connector C 6.0.2
.
我仍然想知道为什么 pip install MySQL-python
默认总是查看目录 C:Program Files (x86)MySQLMySQL Connector C 6.0.2
code>,即使您使用的是 64 位 Python 和/或已将驱动程序安装在不同的位置.
I'm still wondering why pip install MySQL-python
by default always looks into directory C:Program Files (x86)MySQLMySQL Connector C 6.0.2
, even if you're using 64-bit Python and/or have installed the driver at a different location.
任何额外的输入将不胜感激.或者我可能会发布另一个问题,专门询问这一点.
Any additional inputs will be highly appreciated. Or maybe I will post another question ask specifically about the point.