Python error: Unable to find vcvarsall.bat 解决

Python error: Unable to find vcvarsall.bat

在这个url:http://www.biaodianfu.com/python-error-unable-to-find-vcvarsall-bat.html所讲的已经很详细了:

解决方案一:安装Vs2008(实测)

完全的无脑流,安装完问题直接解决。

解决方案二:安装Vs2010(未测试)

上次在电脑上装个Vs2010并不能像 vs2008那样直接解决问题,从网上找到如下解决方案,不知是否可行。

打开“<python安装目录>\Lib\distutils\msvc9compiler.py”

找到 toolskey = “VS%0.f0COMNTOOLS” % version,直接修改为 toolskey = ”VS100COMNTOOLS” 

解决方案三:安装MinGW(实测)

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 下载安装即可。

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

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文件。找到:

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))

修改为:

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))

讲了三个解决方案,安装visualstudio太庞大的,没有试,于是就尝试第三种方法。其中openssl.exe的错误没有碰到,应该是已经有了,而distutils.cfg文件的目录在python2.7下面有点不一样,在Python27\Lib\distutils下面。一直到最后个修改项,最终错误是:

 error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PyInt_AsUnsignedLongLongMask’

没有解决。

中间有个警告,在cygwin中使用dos style的path,设置path CYGWIN=nodosfilewarning 来规避

cygwin warning:

  MS-DOS style path detected: C:\cygwin\home\ADMINI~1\hadoop\/build/native

  Preferred POSIX equivalent is: /home/ADMINI~1/hadoop/build/native

  CYGWIN environment variable option "nodosfilewarning" turns off this warning.

  Consult the user's guide for more details about POSIX paths:

    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

12/02/13 10:34:53 INFO namenode.NameNode: STARTUP_MSG:

python setup.py install build --compiler=mingw32

这个命令尝试也不行



转载于:https://my.oschina.net/zhuhj/blog/376620

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值