ChatGPT解决这个技术问题 Extra ChatGPT

Error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat) when running Python script [duplicate]

This question already has answers here: Cannot find vcvarsall.bat when running a Python script (18 answers) Closed 6 years ago.

Im trying to install numpy with PyCharm but i keep getting this error:

error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).

Can someone please explain to me exactly what i have to do to fix this error(and as simple and detailed as possible)? im using python 3.4.2 (i know this has been answered before but i did not understand it).

Ironically, that question does not have an accepted answer. Also this question needs more details regarding the platform. What version of numpy, PyCharm and windows. And more importantly which parts are 32bit and which are 64 bit.
64bit windows 7 home premium, numpy 1.9.1, pycharm 4.0.4. 64bit python 3.4.2
If you have some other version of Visual Studio, look at the answer by @Gordon Mckeown. (stackoverflow.com/a/32006750/6629)
If you're using Visual Studio, the Microsoft PTVS github has something to say about this error: github.com/Microsoft/PTVS/wiki/Python-Environments

W
Wtower

I was able to fix this on Windows 7 64-bit running Python 3.4.3 by running the set command at a command prompt to determine the existing Visual Studio tools environment variable; in my case it was VS140COMNTOOLS for Visual Studio Community 2015.

Then run the following (substituting the variable on the right-hand side if yours has a different name):

set VS100COMNTOOLS=%VS140COMNTOOLS%

This allowed me to install the PyCrypto module that was previously giving me the same error as the OP.

For a more permanent solution, add this environment variable to your Windows environment via Control Panel ("Edit the system environment variables"), though you might need to use the actual path instead of the variable substitution.


This is very useful. I would like to share my configure on Windows 10 64bit. I have installed python 3.4.3 32bits. There is no 'vcvarsall.bat' in my 'VS140COMNTOOLS' but it is in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC' then I follow your technique. 1. Install Visual Studio 2015 Community Edition with VC++ Programming 2. Create new user variable in System Properties....Advanced....Environment Variables. It's similar this. Variable name: VS100COMNTOOLS Variable value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
This worked for me on Windows 10 64-bit running Python 3.4.3 64-bit using VS120COMNTOOLS (for VS 2013) instead of the 2015 variable.
Thanks worked for me (Win 10 64bit with python 3.4 64 bit). I successfully installed Numpy and matplotlib
win10 64bit with python 3.4 32 bit,it work thanks!
or export VS100COMNTOOLS=$VS140COMNTOOLS if you use bash
C
Community

Python 3.3 and later now uses the 2010 compiler. To best way to solve the issue is to just install Visual C++ Express 2010 for free.

Now comes the harder part for 64 bit users and to be honest I just moved to 32 bit but 2010 express doesn't come with a 64 bit compiler (you get a new error, ValueError: ['path'] ) so you have to install Microsoft SDK 7.1 and follow the directions here to get the 64 bit compiler working with python: Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7

It may just be easier for you to use the 32 bit version for now. In addition to getting the compiler working, you can bypass the need to compile many modules by getting the binary wheel file from this locaiton http://www.lfd.uci.edu/~gohlke/pythonlibs/

Just download the .whl file you need, shift + right click the download folder and select "open command window here" and run

pip install module-name.whl 

I used that method on 64 bit 3.4.3 before I broke down and decided to just get a working compiler for pip compiles modules from source by default, which is why the binary wheel files work and having pip build from source doesn't.

People getting this (vcvarsall.bat) error on Python 2.7 can instead install "Microsoft Visual C++ Compiler for Python 2.7"


Visual C++ 2010 Express is free for 30 days only.
It's free after 30 days too; as long as you register; as far as I can tell?
didn't work for me...even if I use the whl :( [windows 7 64 bits - Python 2.7]
same for me, when i try to install that whl i get: lxml-3.4.4-cp34-none-win_amd64.whl is not a supported wheel on this platform. I'm using windows 8.1 x64 with python 3.4.3
The given link to VS2010 is not working anymore
F
FavorMylikes

I have encountered this problem twice. First time I used VS 2013 and the second time I used VS 2015 with different solution. The first solution on VS 2013 and python 2.7 is:

Click win+R Enter SET VS90COMNTOOLS=%VS120COMNTOOLS% Close all windows Enter pip install again

Now, one year later, I have found an easier method to fix it. This time I use VS 2015 and python 3.4.

Right click on My Computer. Click Properties Advanced system settings Environment variables Add New system variable Enter VS100COMNTOOLSto the variable name Enter the value of VS140COMNTOOLSto the new variable. Close all windows

Now I'm sure you will ask some question what is the VSXXXCOMNTOOLSand what should I do if I use VS2008 or other compiler.

There is a file python\Lib\distutils\msvc9compiler.py, beginning on line 216 we see

def find_vcvarsall(version):
    """Find the vcvarsall.bat file
    At first it tries to find the productdir of VS 2010 in the registry. If
    that fails it falls back to the VS100COMNTOOLS env var.
    """

It means that you must give the productdir of VS 2010 for it, so if you are using python 2.x and

Visual Studio 2010 (VS10):SET VS90COMNTOOLS=%VS100COMNTOOLS%

Visual Studio 2012 (VS11):SET VS90COMNTOOLS=%VS110COMNTOOLS%

Visual Studio 2013 (VS12):SET VS90COMNTOOLS=%VS120COMNTOOLS%

Visual Studio 2015 (VS15):SET VS90COMNTOOLS=%VS140COMNTOOLS%

or if you are using python 3.x and

Visual Studio 2010 (VS10):SET VS100COMNTOOLS=%VS100COMNTOOLS%

Visual Studio 2012 (VS11):SET VS100COMNTOOLS=%VS110COMNTOOLS%

Visual Studio 2013 (VS12):SET VS100COMNTOOLS=%VS120COMNTOOLS%

Visual Studio 2015 (VS15):SET VS100COMNTOOLS=%VS140COMNTOOLS%

And it's the same as adding a new system variable. See the second ways.

Update:Sometimes,it still doesn't work.Check your path,ensure that contains VSxxxCOMNTOOLS


Thanks# @FavorMylikes-- This helped me get closer to an install, but now I get a new error about not being able to find the file c1.exe, so I added it to PATH as well, but this did not fix the issue. If you have any thoughts on this I'd be ecstatic to hear them
Please ensure that you have a compiler with any version,for example 2010 compiler. You can download them at landinghub.visualstudio.com/visual-cpp-build-tools. After installation you could see VSxxxCOMNTOOLS in your path
"cannot find command SET"
P
Patrick

VS 2010 Express is no longer linked to any VS Express pages (that I found). I did find this link to the ISO which I used and it fixed the errors mentioned here.

http://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso

Note: Also make sure you have x86 everything (Python + Postgresql) or you'll get other errors. I did not try x64 everything.


I was running into the same issue because of their heavy push to Visual Studio Community Edition. I was hoping that they may have bundled old dependencies in or something, but I did not find that to be the case. Maybe this is an oversight with the win10 launch? Thanks for finding that link, it fixed the dependency issue for me.
M
MasterAM

I got the same error and ended up using a pre-built distribution of numpy available in SourceForge (similarly, a distribution of matplotlib can be obtained).

Builds for both 32-bit 2.7 and 3.3/3.4 are available. PyCharm detected them straight away, of course.


J
Jiang Donghua

you can download .whl in LFD . Then use "pip install ***.whl" in CMD


p
psych0

Tried to install lxml, grab and other extensions, which requires VS 10.0+ and get the same issue. I find own way to solve this problem(Windows 10 x64, Python 3.4+):

Install Visual C++ 2010 Express (download). (Do not install Microsoft Visual Studio 2010 Service Pack 1 ) 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. Install offline version of Windows SDK for Visual Studio 2010 (v7.1) (download). This is required for 64bit extensions. Windows has builtin mounting for ISOs. Just mount the ISO and run Setup\SDKSetup.exe instead of setup.exe. Create a vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 that contains: CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 Find extension on this site, then put them into the python folder, and install .whl extension with pip: python -m pip install extensionname.whl Enjoy


A
AliSh

you have to check your pip package to be updated to the latest version in your pycharm and then install numpy package. in settings -> project:progLangComp -> Project Interpreter there is a table of packages and their current version (just labelled as Version) and their latest version (labelled as Latest). Pip current version number should be the same as latest version. If you see a blue arrow in front of pip, you have to update it to the latest then trying to install numpy or any other packages that you couldn't install, for me it was pandas which I wanted to install.

enter image description here