[英]python - Getting Pip to use MinGW32 on Windows?
This has been asked and answered a few times, but as you'll see none of the previous answers work for me -- I feel like something had changed to make all the old answers outdated. 这已被问过并回答了几次,但是你会发现以前的答案都不适合我 - 我觉得有些事情已经发生了变化,使得所有旧的答案都过时了。 Or at the very least, I'm in some kind of edge case:
或者至少,我处于某种边缘情况:
On a Windows 7 box, I've installed MinGW32 and Python 2.7 (32 bit version) (I've also tried this with Python 2.6 and got the same results). 在Windows 7机器上,我安装了MinGW32和Python 2.7(32位版本)(我也尝试过使用Python 2.6并获得相同的结果)。
Path environment variable is set correctly. 路径环境变量设置正确。
I've edited cygwincompiler.py
to remove refrences to -mno-cygwin
. 我编辑了
cygwincompiler.py
以删除对-mno-cygwin
cygwincompiler.py
。 And I've put the correct distutils.cfg
file into C:\\Python27\\Lib\\distutils
. 我已将正确的
distutils.cfg
文件放入C:\\Python27\\Lib\\distutils
。
To be clear: distutils.cfg
contains [build] compiler=mingw32
on two lines. 需要说明的是:
distutils.cfg
在两行中包含[build] compiler=mingw32
。
I've also (just to be safe) put pydistutils.cfg
in my %HOME%
directory. 我也(为了安全起见)将
pydistutils.cfg
放在我的%HOME%
目录中。 And put setup.cfg
in my current directory when running pip
. 运行
pip
时将setup.cfg
放在我当前的目录中。 They have same content as distutils.cfg
. 它们与
distutils.cfg
具有相同的内容。
I know this is all working because pip install cython
and pip install pycrypto
both compile successfully. 我知道这一切都有效,因为
pip install cython
和pip install pycrypto
都能成功编译。
However, mysteriously, some packages still give me the unable to find vcvarsall.bat
error. 但是,神秘的是,一些软件包仍然
unable to find vcvarsall.bat
错误。 Two examples are: pyproj and numpy. 两个例子是:pyproj和numpy。
It's as if sometimes pip
knows to use the MinGW compiler and sometimes it doesn't? 好像有时
pip
知道使用MinGW编译器,有时它不会?
Moreover, if I use the MSYS shell that comes with MinGW then magically pip install numpy
succeeds. 此外,如果我使用MinGW附带的MSYS shell,那么神奇地
pip install numpy
成功。 But pip install pyproj
still fails with an unable to find vcvarsall.bat
. 但是
pip install pyproj
仍然失败, unable to find vcvarsall.bat
。
I've tried this out on several machines all with the exact same results. 我已经在几台机器上尝试了这一切,但结果完全相同。
Anybody have any idea what's going on here? 有人知道这里发生了什么吗? Why would
pip
know to use mingw32 to compile some c modules and not others? 为什么
pip
知道使用mingw32编译一些c模块而不是其他模块? Also, why does pip install numpy
work inside the MSYS shell but not inside the cmd shell? 另外,为什么
pip install numpy
在MSYS shell中pip install numpy
工作但不在cmd shell中?
BONUS: Many, many older answers suggest installing Visual Studio 2008 as a way of solving a vcvarsall.bat
error. 奖励:很多很老的答案建议安装Visual Studio 2008作为解决
vcvarsall.bat
错误的一种方法。 But as of this past May, microsoft is no longer distributing this software. 但截至今年5月,微软已不再发布此软件。 Does anyone know of a place where one can still download VS2008?
有谁知道一个人仍然可以下载VS2008的地方? I ask because it's possible that being able to use
vcvarsall.bat
instead of MinGW would solve this problem. 我问,因为能够使用
vcvarsall.bat
代替MinGW可能会解决这个问题。
visual studio express 2008 http://download.microsoft.com/download/8/B/5/8B5804AD-4990-40D0-A6AA-CE894CBBB3DC/VS2008ExpressENUX1397868.iso visual studio express 2008 http://download.microsoft.com/download/8/B/5/8B5804AD-4990-40D0-A6AA-CE894CBBB3DC/VS2008ExpressENUX1397868.iso
Or if you're a student, you can still get Visual Studio 2008 through dreamspark https://www.dreamspark.com/ 或者,如果您是学生,您仍然可以通过dreamspark获取Visual Studio 2008 https://www.dreamspark.com/
IMHO I'd recommend using Visual Studio 2008 because the official distributions of Python are all compiled with Visual Studio and is the "official" windows compiler for cpython. 恕我直言我建议使用Visual Studio 2008,因为Python的官方发行版都是用Visual Studio编译的,并且是cpython的“官方”Windows编译器。 http://mail.python.org/pipermail/python-list/2010-April/573606.html
http://mail.python.org/pipermail/python-list/2010-April/573606.html
FYI Python 33 is compiled with Visual Studio 2010. FYI Python 33是使用Visual Studio 2010编译的。
Finally, you could just install packages from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ 最后,您可以从这里安装软件包: http : //www.lfd.uci.edu/~gohlke/pythonlibs/
I've struggled with this issue for a while, and found that sometimes pip seems to ignore MSYS_HOME
and can't find pydistutils.cfg
, in which case the only recourse seems to be manually copying the pydistutils.cfg
into your virtualenv right before running pip install
. 我一直在努力解决这个问题,并发现有时pip似乎忽略了
MSYS_HOME
并找不到pydistutils.cfg
,在这种情况下,唯一的办法似乎就是在运行之前手动将pydistutils.cfg
复制到你的virtualenv中pip install
。
It sure would be great if someone could definitively figure out why it sometimes finds this file and sometimes does not. 如果有人能够明确地弄清楚为什么它有时会找到这个文件而有时却找不到,那肯定会很棒。 Environment variables seem excessively finicky in MinGW.
MinGW中的环境变量似乎过于挑剔。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.