Python does not consider distutils.cfg

2019-04-29 01:14发布

I have tried everything given and the tutorials all point in the same direction about using mingw as a compiler in python instead of visual c++.

I do have visual c++ and mingw both. Problem started coming when I wanted to install using pip. It always gave Unable to find vcvarsall.bat

So as per suggestions I created a file distutils.cfg under the following path c:/python27/Lib/distutils/ and added the following two lines:

[build]
compiler=mingw32

However, this file has no effect whatsoever. The same error still exists while using pip. I am trying to install numpy by the way currently although the error came earlier also.

3条回答
劫难
2楼-- · 2019-04-29 01:20

Do you happen to use virtualenv as well?

Anyway, use Microsoft Visual C++ Compiler for Python 2.7 and a newer setuptools. The one bundled with virtualenv (3.6) does not support this compiler.

pip install "setuptools>=6.0"

Credits: http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/

查看更多
Emotional °昔
3楼-- · 2019-04-29 01:21

Difficult Solution (Building using the C/C++ compiler)

Are you on Windows 32bit or 64bit? Are you specifying the build when you're compiling? For example, do the following in your shell or bash:

python setup.py build --compiler==mingw32
python setup.py install

Easier Solution (Use pre-built binaries)

If you don't have to compile the program, you can use the unofficial Windows binaries from here

查看更多
手持菜刀,她持情操
4楼-- · 2019-04-29 01:37

Cost me several hours to figure this out but now works like a charm. I am on Windows 64bit and using a scientific Python distribution Enthought Canopy.

  1. Ensure you have installed MinGW and the Compilers you need (C, C++, Fortran..)

  2. Add C:\MingW\bin to your PATH in Environment variables

  3. In C:\Users\MyName\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.6.2.3262.win-x86\Lib\distutils, create with notepad++ or similiar a new file distutils.cfg

Write and save:

[build]
compiler = mingw32

[build_ext]
compiler = mingw32
查看更多
登录 后发表回答