I configured MinGW and distutils so now I can compile extensions using this command:
我配置了MinGW和distutils,所以现在我可以使用这个命令来编译扩展:
setup.py install
MinGW's gcc compiler will be used and package will be installed. For that I installed MinGW and created distutils.cfg file with following content:
将使用MinGW的gcc编译器并安装包。为此我安装了MinGW并创建了distutils。cfg文件包含以下内容:
[build]
compiler = mingw32
It's cool but now I'd like to use all pip benefits. Is there a way to use the same MinGW's gcc compiler in pip? So that when I run this:
很酷,但是现在我想用所有的pip收益。是否有方法在pip中使用相同的MinGW的gcc编译器?所以当我运行这个:
pip install <package name>
pip will use MinGW's gcc compiler and compile C code if needed?
如果需要,pip将使用MinGW的gcc编译器并编译C代码?
Currently I get this error: Unable to find vcvarsall.bat
. Seems pip doesn't know that I have gcc compiler. How can I configure pip to use gcc compiler?
目前我有这个错误:找不到vcvarsall.bat。似乎pip不知道我有gcc编译器。如何配置pip以使用gcc编译器?
3 个解决方案
#1
88
- install MinGW with C++ Compiler option checked
- 使用c++编译器选项安装MinGW。
- add
C:\MinGW\bin
to your PATH - 添加C:\MinGW\bin到您的路径。
- in
PYTHONPATH\Lib\distutils
, create a filedistutils.cfg
and add these lines: - 在PYTHONPATH\Lib\distutils中,创建一个文件distutils。cfg和添加这些线:
[build] compiler=mingw32
(构建)编译器= mingw32
#2
14
Even though configuration file solves this problem, it's not always an option. I had the same issue for my command line installation process and I was not able to change config files on all the machines and python distributions.
尽管配置文件解决了这个问题,但它并不总是一个选项。我在命令行安装过程中遇到了同样的问题,我不能在所有的机器和python发行版上修改配置文件。
This is my solution:
这是我的解决方案:
For mingw32 and packages, which use VC++ as default:
对于mingw32和包,使用vc++作为默认值:
pip install --global-option build_ext --global-option --compiler=mingw32 <package_zip>
For Visual C++ on WinPython, which uses mingw32 as default:
对于WinPython的Visual c++,它使用mingw32作为默认值:
pip install --global-option build_ext --global-option --compiler=msvc <package_zip>
#3
4
Maybe you didn't put distutils.cfg in the right location? I solved the same problem creating a file called pydistutils.cfg inside c:\Documents and Settings\myuser, with the same content as yours. I did this way and it works. HTH
也许你没把它放进去。cfg在正确的位置吗?我解决了同样的问题,创建了一个名为pydistutils的文件。cfg内部的文件,文件和文件,与你的内容相同。我这样做了,而且很有效。HTH
#1
88
- install MinGW with C++ Compiler option checked
- 使用c++编译器选项安装MinGW。
- add
C:\MinGW\bin
to your PATH - 添加C:\MinGW\bin到您的路径。
- in
PYTHONPATH\Lib\distutils
, create a filedistutils.cfg
and add these lines: - 在PYTHONPATH\Lib\distutils中,创建一个文件distutils。cfg和添加这些线:
[build] compiler=mingw32
(构建)编译器= mingw32
#2
14
Even though configuration file solves this problem, it's not always an option. I had the same issue for my command line installation process and I was not able to change config files on all the machines and python distributions.
尽管配置文件解决了这个问题,但它并不总是一个选项。我在命令行安装过程中遇到了同样的问题,我不能在所有的机器和python发行版上修改配置文件。
This is my solution:
这是我的解决方案:
For mingw32 and packages, which use VC++ as default:
对于mingw32和包,使用vc++作为默认值:
pip install --global-option build_ext --global-option --compiler=mingw32 <package_zip>
For Visual C++ on WinPython, which uses mingw32 as default:
对于WinPython的Visual c++,它使用mingw32作为默认值:
pip install --global-option build_ext --global-option --compiler=msvc <package_zip>
#3
4
Maybe you didn't put distutils.cfg in the right location? I solved the same problem creating a file called pydistutils.cfg inside c:\Documents and Settings\myuser, with the same content as yours. I did this way and it works. HTH
也许你没把它放进去。cfg在正确的位置吗?我解决了同样的问题,创建了一个名为pydistutils的文件。cfg内部的文件,文件和文件,与你的内容相同。我这样做了,而且很有效。HTH