打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python error: Unable to find vcvarsall.bat
error: Unable to fin

I'm trying to install dulwich for bzr-git.now, I use Python 2.6 based bazaar.(I use msys.)

My steps are as follows:

$ bzr branch lp:dulwich$ cd dulwich/$ python setup.py installrunning installrunning buildrunning build_pycreating build::creating build\lib.win32-2.6\dulwich\tests::running build_extbuilding 'dulwich._objects' extensionerror: Unable to find vcvarsall.bat

If you know any hints, tell me please.

asked May 12 '10 at 10:24
okada
1,451364
3  
For future reference it would be nice to see on what platform do you use this. –  T?r?k Gábor Aug 31 '11 at 10:17
    
5  
If you think this is a ludicrously cryptic and unhelpful error message, please vote for the bug at bugs.python.org/issue2943 –  Colonel Panic Nov 20 '13 at 14:11
1  
For comparison, in analogous situations the Ruby package manager Gem says: "Please update your PATH to include build tools or download the DevKit from 'rubyinstaller.org/downloads'; and follow the instructions at 'github.com/oneclick/rubyinstaller/wiki/…; –  Colonel Panic Nov 20 '13 at 14:13
add comment

15 Answers

For Windows installations:

While running setup.py for package installations Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path in VS90COMNTOOLS environment variable before calling setup.py.

If you have Visual Studio 2010 installed, execute

SET VS90COMNTOOLS=%VS100COMNTOOLS%

or with Visual Studio 2012 installed (Visual Studio Version 11)

SET VS90COMNTOOLS=%VS110COMNTOOLS%

or with Visual Studio 2013 installed (Visual Studio Version 12)

SET VS90COMNTOOLS=%VS120COMNTOOLS%
answered May 11 '12 at 20:39
fmuecke
3,92011020
16  
It did for me :( –  fmuecke May 22 '12 at 19:33
2  
@Gili: It looks like this problem is due to spaces in the variable, try wrapping it within quotes. For me %VS100COMNTOOLS%="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools" –  legends2k Oct 5 '12 at 11:44
5  
This won't work for many things, because Python relies on VS2008. Have a look at this answer: stackoverflow.com/questions/6551724/… –  shezi Feb 16 '13 at 11:35
66  
WARNING!!! This is WRONG answer. You should not under any circumstances compile Python C extension using different (version of) compiler that the one used to compile Python itself as those two (versions of) compilers will probably have incompatible C runtime libraries. See this answer for more details. –  Piotr Dobrogost Apr 29 '13 at 19:35
7  
You can download the free Visual C++ 2008 Express Edition from go.microsoft.com/?linkid=7729279, which will set the VS90COMNTOOLS environment variable during installation and therefore build with a compatible compiler. –  Eric Smith Dec 6 '13 at 18:38
show 8 more comments

I found the solution. I had the exact same problem, and error, installing 'amara'. I had mingw32 installed, but distutils needed to be configured.

  1. I have Python 2.6 that was already installed.
  2. I installed mingw32 to C:\programs\mingw\
  3. Add mingw32's bin directory to your environment variable: append c:\programs\MinGW\bin; to the PATH
  4. Edit (create if not existing) distutils.cfg file located at C:\Python26\Lib\distutils\distutils.cfg to be:

    [build]compiler=mingw32
  5. Now run easy_install.exe amara.

Make sure environment is set by opening a new cmd.exe.

answered May 15 '10 at 3:37
ninMonkey
3,9054927
1  
'[build]' and 'compiler=mingw32' should be on two separate lines. The markup seems to have messed it slightly. –  Jonathan Hartley Jul 14 '10 at 9:15
31  
This works great for Python2.6, but for some reason I can't get it to work on Python2.7. It works if I downloading my package source and install using 'python setup.py install --compile=mingw32', but for some reason using easy_install or pip still tries to find vcvarsall. –  Jonathan Hartley Jul 16 '10 at 16:11
2  
I finally got scikits.image to install in Python(x,y) 2.7 by adding C:\msysgit\mingw\mingw32\bin and C:\msysgit\mingw\bin to the user PATH and restarting Spyder before running pip install again –  endolith Nov 26 '11 at 6:11
12  
There is no need ever to reboot because of an environment variable change. Opening a new cmd.exe process is enough. –  Tomalak Jun 29 '12 at 8:47
9  
I still couldn't fix this. This is the error: gcc: error: unrecognized command line option '-mno-cygwin' error: Setup script exited with error: command 'gcc' failed with exit status 1 after easy_install.exe amara –  user Sep 17 '13 at 13:17
show 2 more comments

You can install compiled version from http://www.lfd.uci.edu/~gohlke/pythonlibs/

answered May 12 '11 at 19:55
VolodymyrB
1,507147
6  
just a tip: you can install the package from this site in virtualenv by running easy_install binary_installer_built_with_distutils.exe in virtualenv, accoding to this answer. –  yangzh Sep 7 '13 at 4:32
    
+1 This is best solusion –  Tuan Hoang Anh Sep 28 '13 at 18:15
    
Every Python Windows dev should know about this –  High schooler Nov 26 '13 at 18:12
add comment

I just had this same problem, so I'll tell my story here hoping it helps someone else with the same issues and save them the couple of hours I just spent:

I have mingw (g++ (GCC) 4.6.1) and python 2.7.3 in a windows 7 box and I'm trying to install PyCrypto.

It all started with this error when running setup.py install:

error: Unable to find vcvarsall.bat

Easily solved after googling the error by specifying mingw as the compiler of choice:

setup.py install build --compiler=mingw32

The problem is that then I got a different error:

configure: error: cannot run C compiled programs.

It turns out that my anti-virus was blocking the execution of a freshly compiled .exe. I just disabled the anti-virus "resident shield" and went to the next error:

cc1.exe: error: unrecognized command line option '-mno-cygwin' error: command 'gcc' failed with exit status 1

This solved it: "Either install a slightly older version of MinGW, or edit distutils\cygwinccompiler.py in your Python directory to remove all instances of -mno-cygwin." (from here)

Now, I can finally start working.

answered May 8 '12 at 15:31
fpessoa
64837
4  
You will also need a MinGW-compatible version of the Python library. See eli.thegreenplace.net/2008/06/28/… for more information –  Gili May 22 '12 at 15:16
add comment

At least I found my solution from drawing feedback from other answers using the Visual Studio C++ 2008 compilers rather than installing through the mingw32 path.

Here's the steps:

  1. Download and install specifically Visual Studio C++ 2008 Express Edition.

    Update for x64 Compilers: By default this will only give you a 32-bit compiler. I learned (from here and here) that you can download specifically the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 which gives you a x64 compiler for VC++ 2008 (VC++ 9.0) if you need it. Just when you are installed it, you can uncheck everything except Developer Tools >> Visual C++ Compilers which will keep you from installing all the extra SDK tools that you may not need.

    tl;dr: If you want the x64 compilers for VC++ 2008, download specifically the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 and uncheck everything except Developer Tools >> Visual C++ Compilers during install.

    Note: If you have both a 32- and 64-bit Python installation, you may also want to use virtualenv to create separate Python environments to use one or the other at a time without messing with your path to choose which Python version to use.

  2. Note: Apparently, you may be able to skip all of this by copying a few batch files according to @srodriguex following this answer. If that works great, otherwise, here is at least what worked for me.

    Open up a cmd.exe

  3. Before you try installing something which requires C extensions, run the following batch file to load the VC++ compiler's environment into the session (i.e. environment variables, the path to the compiler, etc).

    Execute:

    • 32-bit Compilers:

      Note: 32-bit Windows installs will only have C:\Program Files\ as expected

      "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"

    • 64-bit Compilers:

      "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars64.bat"

      Note: Yes, the native 64-bit compilers are in Program Files (x86). Don't ask me why.
      Additionally, if you are wondering what the difference between vcvars64.bat and vcvarsx86_amd64.bat or more importantly the difference between amd64 and x86_amd64, the former are for the native 64-bit compiler tools and the latter are the 64-bit cross compilers that can run on a 32-bit Windows installation.

    Update:
    If for some reason you are getting error: ... was unexpected at this time. where the ... is some series of characters, then you need to check that you path variable does not have any extraneous characters like extra quotations or stray characters. The batch file is not going to be able to update your session path if it can't make sense of it in the first place.

  4. If that went well, you should get one of the following messages depending on which command you ran:

    For the 32-bit compiler tools:
    Setting environment for using Microsoft Visual Studio 2008 x86 tools.

    For the 64-bit compiler tools:
    Setting environment for using Microsoft Visual Studio 2008 x64 tools.

  5. Now, run the setup via python setup.py install or pip install pkg-name

  6. Hope and cross your fingers that the compiler actually works today.

answered Aug 4 '13 at 16:48
Jaxrtech
936414
    
Cannot recommend enough that you do go through the pain of moving straight to 64 bit. It's just a matter of time before you'll need more than 4gb of address space. I speak from painful experience after having gone 32 bit because it was much easier, then having to uninstall everything including dependencies and going 64 bit. Almost a whole weekend. –  Thomas Browne Feb 9 at 9:31
    
Then again, I forget how many people are going to have to use Python for much larger tasks like that. And @ThomasBrowne, I'm sure that was a painful and an unnecessary evil of an experience. I'm looking into it, and hopefully I can find something. The main issue was that Visual Studio C++ 2008 Express does not come with a 64-bit compiler, but I'm sure its around here somewhere. –  Jaxrtech Feb 9 at 20:25
    
Just updated it with more information covering how to also get the 64-bit compilers if you need them. –  Jaxrtech Feb 11 at 21:04
    
In my case, I follow step 1 above and skipped the rest following this answer. Now I'm able to install packages avoiding the annoyance of running .bat. –  srodriguex Apr 13 at 14:32
    
@srodriguex well in that case, it looks like Python is assuming that the 64-bit compiler tools get loaded into the PATH using that it is looking for ...\VC\bin\vcvarsamd64.bat and ...\VC\bin\amd64\vcvarsamd64.bat. –  Jaxrtech Apr 13 at 19:58
show 1 more comment

I have python 2.73 and windows 7 .The solution that worked for me was:

  1. Added mingw32's bin directory to environment variable: append PATH with C:\programs\mingw\bin;
  2. Created distutils.cfg located at C:\Python27\Lib\distutils\distutils.cfg containing:

    [build]compiler=mingw32

To deal with MinGW not recognizing the -mno-cygwin flag anymore, remove the flag in C:\Python27\Lib\distutils\cygwincompiler.py line 322 to 326, so it looks like this:

  self.set_executables(compiler='gcc -O -Wall',                         compiler_so='gcc -mdll -O -Wall',                         compiler_cxx='g++ -O -Wall',                         linker_exe='gcc',                         linker_so='%s %s %s'                                    % (self.linker_dll, shared_option,                                       entry_point))
d vcvarsall.bat
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
彻底解决 error: Unable to find vcvarsall.bat
python env setup
Python的Cython在Windows环境下的部署安装
2. Writing the Setup Script
Building From Source on Windows
windows7环境下theano安装
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服