Windows 10 and Unable to find vcvarsall.bat

2019-01-17 09:06发布

When I try to build one package:

C:\Linter\intlib\PYTHON>python setup.py build

I get this error message:

running build

running build_ext

building 'LinPy' extension

error: Unable to find vcvarsall.bat

This is my Python version:

Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)] on win32

And I'm working on Windows 10 x64. I know about this thread and dozens of others (like this and this and the list goes on). So, I guess I tried almost everything, but nothing works. It seems like all those threads have become outdated, so I need some new receipt. BTW. I tried this:

SET VS90COMNTOOLS=%VS100COMNTOOLS%

And this (in Visual Studio 2015 Visual Studio Command Prompt):

set DISTUTILS_USE_SDK=1

I looked for vcvarsall.bat everywhere on my machine, but could not find it.

I investigated this folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools, but it does not contain any .bat files. Anyway, after all my manipulations python setup.py build still raises the very same error. So, I need help. Thanks!

6条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-17 09:12

The issue is caused because you don't have a compiler installed for the receptive build you are trying to run.


The following is what you may require as per the MS Python Engineering community,

Python Version  |You will need
------------------------------------
3.5 and later   |Visual C++ Build Tools 2015 or Visual Studio 2015
3.3 and 3.4     |Windows SDK for Windows 7 and .NET 4.0
                |(Alternatively, Visual Studio 2010 if you have access to it)
2.6 to 3.2      |Microsoft Visual C++ Compiler for Python 2.7

You will need to install: Windows SDK for Windows 7 and .NET 4.0 or VS 2010


Source: How to deal with the pain of “unable to find vcvarsall.bat”

查看更多
一纸荒年 Trace。
3楼-- · 2019-01-17 09:16

Step 1: Install Visual C++ 2010 Express from here.

(Do not install Microsoft Visual Studio 2010 Service Pack 1 )

Step 2: Remove all the Microsoft Visual C++ 2010 Redistributable packages from Control Panel\Programs and Features. If you don't do those then the install is going to fail with an obscure "Fatal error during installation" error.

Step 3: Install offline version of Windows SDK for Visual Studio 2010 (v7.1) from here. This is required for 64bit extensions. Windows has builtin mounting for ISOs like Pismo.

Step 4: You need to install the ISO file with Pismo File Mount Audit Package. Download Pismo from here

Step 5: Right click the downloaded ISO file and choose mount with Pismo. Thereafter, install the Setup\SDKSetup.exe instead of setup.exe.

Step 6a: Create a vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 by changing directory to C:\Program Files (x86)\Microsoft Visual Studio version\VC\ on the command prompt. Type command on the command prompt: cd C:\Program Files (x86)\Microsoft Visual Studio version\VC\r

Step 6b: To configure this Command Prompt window for 64-bit command-line builds that target x86 platforms, at the command prompt, enter: vcvarsall x86</p>

查看更多
倾城 Initia
4楼-- · 2019-01-17 09:18

I did a search for a python wheel of LinPy unfortunately there happened to be none.

Cython has a very good workaround for setting up a windows C/C++ compiler for builds in python. You can find it here. Since you've already downloaded the SDK/.NET framework, you should go ahead and install it as it will be needed as part of the steps. If your system reports there is already an existing version, you may uninstall, restart and reinstall.

A hackish alternative is to search for vcvars32.bat or vcvarsall.bat (these batch files are only to set up environment variables for compile time) in your Visual studio installation directory. If you don't find any, then you should install the SDK. I managed to do a work around by hardcoding the path to vcvars32.bat or vcvarsall.bat in the find_vcvarsall function of C:\Python34\Lib\distutils\msvc9compiler.py, but there is a missing library (ISL - Integer Set Library). I think it's because I am using VC11.

enter image description here

I don't have the SDK, but you may try these and see what happens from your end

查看更多
对你真心纯属浪费
5楼-- · 2019-01-17 09:25

You can ease your pains with Microsoft compilers for Python 3.4 by installing mingwpy or libpython (not both):

pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy

conda install libpython

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-17 09:27

To use mingwpy instead of the MSVC compiler create a file named pydistutils.cfg in the folder %USERPROFILE% with the following content:

[config]
compiler=mingw32
[build]
compiler=mingw32
[build_ext]
compiler=mingw32

see also How to use MinGW's gcc compiler when installing Python package using Pip?

查看更多
劳资没心,怎么记你
7楼-- · 2019-01-17 09:30

To add to what Ani Menon answered and addressing Jacobian's(OP) issues he had in response... I had the same issue so I followed this StackOverflow post regarding changing the version number of .NET in the registry temporarily. It's probably a good idea to change the registry value back after.

https://stackoverflow.com/a/33260090/4637870

This succeeded in getting me past the .NET 4 not installed error, but then I was presented with another error towards that the installation was unsuccessful.

I had to remove both the x86 and x64 instances of the Microsoft Visual C++ 2010 Redistributable and let the SDK install it for me. After doing so I was able to make it all the way through the setup without error. This is where I got my information from:

Forum: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/381299c9-1bf4-44d4-989c-871735c6b4ca/windows-sdk-for-windows-7-and-net-framework-4-wont-install?forum=windowssdk

Fix: https://support.microsoft.com/de-de/help/2717426/windows-sdk-fails-to-install-with-return-code-5100

I tried running pip on the same package and the error: Unable to find vcvarsall.bat is gone. Now I have a ValueError: ['path'] but thats another issue. Hope this information helps.

For info on my setup im running windows 7 and python 3.4

查看更多
登录 后发表回答