54

I tried to install Scrapy for Python 2.7.8 (anaconda 2.1.0) 32-bit using

pip install scrapy

And I got this error

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

I have followed the solutions found in these stackover flow questions. Nothing worked.

Microsoft Visual C++ Compiler for Python 2.7

Can't find vcvarsall.bat file

error: Unable to find vcvarsall.bat

Getting "error: Unable to find vcvarsall.bat" when running "pip install numpy" on windows7 64bit

pip install gives error: Unable to find vcvarsall.bat

How do I point easy_install to vcvarsall.bat?

pip install MySQL-python returns unable to find vcvarsall.bat

This is the error, and a few lines above and below it:

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt
-> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution opt
ion: 'bugtrack_url'

  warnings.warn(msg)

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


----------------------------------------
Command "C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:
\\Users\\San\\AppData\\Local\\Temp\\pip-build-wp6ei6r9\\lxml\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record C:\Users\San\AppData\Local\Temp\pip-kfkzr_67-r
ecord\install-record.txt --single-version-externally-managed --compile" failed w
ith error code 1 in C:\Users\San\AppData\Local\Temp\pip-build-wp6ei6r9\lxml

I have both Microsoft Visual Studio 12.0, and Microsoft visual C++ compiler package for Python 2.7, both of which have the vcvarsall.bat file.


I have a system variable that is called 'VS120COMNTOOLS' and is its path is set to

C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\

I also added both paths to my environment variables. I've also tried just adding one, and then the other. My Path looks like this

C:\Program Files\Java\jdk1.7.0_25\bin;\Python27;\Python2\python.exe;C:\Python27\Scripts\;C:\Users\San\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\;C:\Program Files\Microsoft Visual Studio 12.0\VC\;

I also updated by my setup tools (I think to version 8), which should autodetect Microsoft Visual C++ Compiler for Python 2.7. However, I'm still getting the same error.


I have also tried using

easy_install scrapy

And I get this error

error: Setup script exited with error: Microsoft Visual C++ 10.0 is required (Un

able to find vcvarsall.bat).


I also have the following in my registry

HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\12.0\Setup\VC\ProductDir
Community
  • 1
  • 1
SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
  • 1
    What python version are you using? 2.7.x? Also, could you provide a little more context on the error (a few lines before and after)? I do get a similar "can't find vcvarsall" but it's just a warning, scrapy installs ok with python 2.7.9. – Joaquin Sargiotto Dec 27 '14 at 19:47
  • I am using Python 2.7.8 (anaconda 2.1.0) 32-bit. I tried an environment with Python 2.7.9 and it still didn't work. I updated the question to include a couple lines above and below the error. – SantoshGupta7 Dec 28 '14 at 04:40
  • 2
    Try installing: [Microsoft Visual C++ Compiler for Python 2.7](https://www.microsoft.com/en-us/download/details.aspx?id=44266) – kenorb May 26 '15 at 11:18
  • I have faced the same problem. Then I upgraded the pip as suggested. python -m pip install --upgrade pip – arshovon Jun 23 '16 at 17:10
  • I had this issue in Python 3.4 and I simply had to update `pip` to the latest version. – Blairg23 Jul 21 '16 at 16:48
  • Check for [How to deal with the pain of “unable to find vcvarsall.bat”](https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/) to resolve from the root – Vinod Srivastav Jan 11 '18 at 14:24

5 Answers5

52

I have tried all suggestions and found my own simple solution.

The problem is that codes written in external environment like C need compiler. Look for its own VS environment, i.e. VS 2008.

Currently my machine runs VS 2012 and faces Unable to find vcvarsall.bat. I studied codes that i want to install to find the VS version. It was VS 2008. i have add to system variable VS90COMNTOOLS as variable name and gave the value of VS120COMNTOOLS.

You can find my step by step solution below:

  1. Right click on My Computer.
  2. Click Properties
  3. Advanced system settings
  4. Environment variables
  5. Add New system variable
  6. Enter VS90COMNTOOLS to the variable name
  7. Enter the value of current version to the new variable.
  8. Close all windows

Now open a new session and pip install your-package

Fatih1923
  • 2,665
  • 3
  • 21
  • 28
  • 9
    I had `VS140COMNTOOLS` installed and added `%VS140COMNTOOLS%` to variable named `VS90COMNTOOLS` and it worked. – dashesy Dec 14 '15 at 18:05
  • 1
    Wow it actually worked! I had VS140 as well and setting it with `SET VS90COMNTOOLS=%VS140COMNTOOLS%` worked :D – Cobertos Oct 01 '16 at 01:57
  • This Microsoft blog post was very helpful to me...apparently, different versions of Python require different compilers which may not even be installed...https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/ – ChaimG Feb 26 '17 at 07:41
  • did not work for me. – john k Sep 19 '17 at 17:29
  • I had `VS 10,12,14` installed and I can only see `VS120COMNTOOLS` in varibales. But error show I need `VS 14.0` installed. I tried different combnations. Can someone help? What am I missing? The value of `VS120COMNTOOLS` is `C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\` but `Tools` folder is missing in `Common7` – srikanth peetha Oct 19 '17 at 11:04
51

After doing a lot of things, I upgraded pip, setuptools and virtualenv.

  1. python -m pip install -U pip
  2. pip install -U setuptools
  3. pip install -U virtualenv

I did steps 1, 2 in my virtual environment as well as globally. Next, I installed the package through pip and it worked.

Trang Oul
  • 134
  • 1
  • 8
StatusQuo
  • 1,436
  • 1
  • 13
  • 13
  • 2
    after trying a bunch of other posts, this is the only on that worked for me! Thanks! – Denis May 06 '16 at 14:30
  • 1
    I would send you money if I knew who you were. – Jason Strimpel May 20 '17 at 07:08
  • After trying to set variables, etc.. this was actually what fixed it for me! – George TG Jul 19 '17 at 09:54
  • That fixed my problem too, I just had to update virtualenv to 15.1 which comes with the latest pip 9.0. pip 7.0 seems to be the problem here. – Maxime Oct 24 '17 at 21:38
  • This worked for me too . thanks so much . If anyone gets cl.exe not found or somefile not found error while installing , just install the "Twisted" and "lxml" libraries from unofficial source and u can then easily install Scrapy from pip without errors . link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted – Natesh bhat Feb 18 '18 at 05:33
30

Try installing this, it's a known workaround for enabling the C++ compiler for Python 2.7.

In my experience, when pip does not find vcvarsall.bat compiler, all I do is opening a Visual Studio console as it set the path variables to call vcvarsall.bat directly and then I run pip on this command line.

avenet
  • 2,894
  • 1
  • 19
  • 26
  • Already installed the C++ compiler for Python 2.7. I opened both Visual Studio Express 2013 for Web and for Desktop and tried installing scrapy again, same result. – SantoshGupta7 Dec 28 '14 at 04:50
  • 1
    I tried installing scrapy (via `pip install scrapy`) on Python 2.7.9, after installing [this](http://www.microsoft.com/en-us/download/details.aspx?id=44266) and it worked perfectly. I will try installing Anaconda 2.1.0. – avenet Dec 28 '14 at 11:33
  • 1
    It worked perfectly for me (using Anaconda 2.1.0). I recommend you cleaning all your dev environment (uninstalling all which is not mandatory and only adding http://www.microsoft.com/en-us/download/details.aspx?id=44266) and trying it again, it should work without the vcvarsall.bat problem. – avenet Dec 28 '14 at 11:44
  • 1
    On the logs, looks like Python 3.4 is the one trying to build the extensions and not Python 2.7, this could be the problem. – avenet Dec 28 '14 at 16:49
  • 2
    For avoiding compilation via C++ extensions, you can try this [lxml extension package](http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml) which comes with all of the compiled stuff per Python installation. After that just run the install again, and it should skip lxml installation. – avenet Dec 28 '14 at 16:50
  • Good catch. I checked the version of python it was running and it was python 2.7. I also tried it in the python27 folder too just to be save. same result I installed the lxml extension package. Same result. – SantoshGupta7 Dec 28 '14 at 23:42
  • Is there a Python 3 option? Using Anaconda distribution, I unistalled Python 3 and install Python 2.... Works now, but I'd like to use Python 3 instead. – openwonk Jan 14 '16 at 17:25
3

I was getting the same error in python 3.4.3 too and I tried using the solutions mentioned here and elsewhere with no success.

Microsoft makes a compiler available for Python 2.7 but it didn't do me much good since I am on 3.4.3.

Python since 3.3 has transitioned over to 2010 and you can download and install Visual C++ 2010 Express for free here: https://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express

Here is the official blog post talking about the transition to 2010 for 3.3: http://blog.python.org/2012/05/recent-windows-changes-in-python-33.html

Because previous versions gave a different error for vcvarsall.bat I would double check the version you are using with "pip -V"

C:\Users\B>pip -V
pip 6.0.8 from C:\Python34\lib\site-packages (python 3.4)

As a side note, I too tried using the latest version of VC++ (2013) first but it required installing 2010 express.

From that point forward it should work for anyone using the 32 bit version, if you are on the 64 bit version you will then get the ValueError: ['path'] message because VC++ 2010 doesn't have a 64 bit compuler. For that you have to get the Microsoft SDK 7.1. I can't hyperlink the instruction for 64 bit because I am limited to 2 links per post but its at

Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7

Community
  • 1
  • 1
Broccoli Soup
  • 557
  • 4
  • 7
  • I am using also Python 3.4. Installing Visual C++ 2010 Express has not solved the problem for me. Actually the 2nd comment by avenet on the above answer has solved the problem. – gm2008 Apr 09 '15 at 11:25
1

Here too I can reproduce this problem with scrapy and psycopg2 (both require C++ compiling), even though I have Microsoft Visual C++ Compiler for Python 2.7 installed.

It has to be noted that I use virtualenv. From your post I'm not sure whether you do the same.

Anyway I tried to skip the activation of the virtual environment. Then both scrapy and psycopg2 installed fine.

My hypothesis: there is a conflict between this 2014 C++ compiler for Python and virtualenv. I do not know why nor how to solve it (and I'd be glad if someone can suggest a workaround).

Community
  • 1
  • 1
Hugues Fontenelle
  • 5,275
  • 2
  • 29
  • 44