Python 2.7 64-bit erroneously refer to 32-bit (x86) for include files

半城伤御伤魂 提交于 2021-02-17 05:44:26

问题


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)\MySQL\MySQL Connector C 6.0.2\include".

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.

I'm wondering did I miss any setting pointing python and its compiler to 64-bit instead of x86?

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.

Sample screen output of calling Visual C++ compiler:

...
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\
Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- 
/DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files 
(x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\my\test-pip\venv-x64\include -
IC:\my\test-pip\venv-x64\PC /Tc_mysql.c /Fobuild\temp.win-amd64-
2.7\Release\_mysql.obj /Zl
...

回答1:


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:\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

In this example, I have fully installed 64-bit version of MySQL Connector C in customized location of C:\my\install\MySQL-x64\MySQL Connector C 6.0.2\.

I'm still wondering why pip install MySQL-python by default always looks into directory C:\Program Files (x86)\MySQL\MySQL 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.



来源:https://stackoverflow.com/questions/64165600/python-2-7-64-bit-erroneously-refer-to-32-bit-x86-for-include-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!