I configured MinGW and distutils so now I can compile extensions using this command:
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:
[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 install <package name>
pip will use MinGW’s gcc compiler and compile C code if needed?
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?
- install MinGW with C++ Compiler option checked
C:\MinGW\binto your PATH
PYTHONPATH\Lib\distutils, create a file
distutils.cfgand add these lines:
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.
This is my solution:
For mingw32 and packages, which use VC++ as default:
pip install --global-option build_ext --global-option --compiler=mingw32 <package_zip>
For Visual C++ on WinPython, which uses mingw32 as default:
pip install --global-option build_ext --global-option --compiler=msvc <package_zip>
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