easy_install遇上Unable to find vcvarsall.bat

  首先说明这个方法并不是万能的,也查了些资料,说安装了vs这个是可以通过的,但我的电脑上貌似行不通,不管是微软的vs,还是玩魔兽的vs客户端都有还是行不通,也有可能是我装的是vs2010、vs2012版本太高了,所需要的文件没有了, 据说是要vs2008,这个我就没有去尝试啦,有兴趣的朋友可以去试下,记得把结果告诉我哈。

  现在我们用另一种无需安装庞大的vs的方法

1、下载安装MinGW,下载地址为:http://sourceforge.net/projects/mingw/files/latest/download?source=files

2、在MinGW的安装目录下找到bin文件夹,找到mingw32-make.exe,复制一份更名为make.exe

3、把MinGW的路径添加到环境变量path中,比如我把MinGW安装到D:\MinGW\中,就把D:\MinGW\bin添加到path中;

4、在<python安装目录>\distutils增加文件distutils.cfg,在文件里输入

[build]
compiler=mingw32

保存;

5、执行原先的模块安装,发现还是报错,报错内容为:error: command ’gcc’ failed: No such file or directory  解决方案是将D:\MinGW\lib再添加到PATH中。

6、如果安装过程中出现 error: Could not find ‘openssl.exe’ 则直接到http://pypi.python.org/pypi/pyOpenSSL/0.13 下载安装即可。

6、再次执行时安装模块时,发现如下错误:

D:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall “-ID:\Program Files\Python27\inc
lude” “-ID:\Program Files\Python27\include” “-ID:\Program Files\Python27\PC” -c
../libdasm.c -o build\temp.win32-2.7\Release\..\libdasm.o
cc1.exe: error:unrecognized command line option ‘-mno-cygwin’
error: command ‘gcc’ failed with exit status 1

原因是gcc 4.6.x 以后不再接受-mno-cygwin为了解决这个问题需要修改<python安装目录>\distutils\cygwinccompiler.py文件。找到:

1
2
3
4
5
6
7
self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
                            compiler_so='gcc -mno-cygwin -mdll -O -Wall',
                            compiler_cxx='g++ -mno-cygwin -O -Wall',
                            linker_exe='gcc',
                            linker_so='%s -mno-cygwin %s %s'
                                       % (self.linker_dll, shared_option,
                                          entry_point))

修改为:

1
2
3
4
5
6
7
self.set_executables(compiler='gcc -O -Wall',
                            compiler_so='gcc -mdll -O -Wall',
                            compiler_cxx='g++ -mno-cygwin -O -Wall',
                            linker_exe='gcc',
                            linker_so='%s -mno-cygwin %s %s'
                                       % (self.linker_dll, shared_option,
                                          entry_point))

至此,大功告成!

MinGW

posted @ 2013-05-29 11:16  诸葛风流  阅读(6905)  评论(0编辑  收藏  举报