21

I am on a windows 10 machine and recently moved from python 2.7 to 3.5. When trying to install lxml through pip, it stops and throws this error message-

building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

I have a working copy of VS 2015 installed. When I try to install the visual cpp tools through that link, it says that Microsoft Visual Studio 2015 is already installed on the machine. I also tried installing visual studio c++ 2015 redistributables, both 64 and 32 bit versions, but both of them say that there's another version of the product already installed.
typing set in the command prompt includes this -

VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\

Which means that the path is set.
This is probably the only resource I could find on SO, but the answer suggests rolling back to Python 3.4.3 from 3.5. Has anybody resolved problems of this kind?
Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
EDIT: I managed to install it using the precompiled binary (Thanks Paul), but I would still like to know what's causing this.

sophros
  • 14,672
  • 11
  • 46
  • 75
Zeokav
  • 1,653
  • 4
  • 14
  • 29
  • get the precompiled binary for lxml. http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml – Paul Rooney Aug 15 '16 at 05:02
  • 2
    But that's just a workaround, right? I would also like to know why the error is coming up even though I have everything installed and the paths set up. I will, however, install the binary in case I can't find anything else, thanks! – Zeokav Aug 15 '16 at 05:07
  • 1
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools I am also facing exact same thing while installing **mysqlclient**. Workaround or proper solution anything will do. – wadhwa94 Sep 16 '16 at 16:56
  • Maybe this can help you https://stackoverflow.com/questions/29846087/microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat/55575792#55575792 – Alejandro Alcalde Apr 08 '19 at 15:24
  • Or this one: https://stackoverflow.com/questions/44951456/pip-error-microsoft-visual-c-14-0-is-required – sophros Jan 13 '20 at 15:10

8 Answers8

28

Have you checked that when you installed Visual Studio, you installed the C++ compiler? It seems like a silly question, but this is the mistake I made. Check by going into the setup for visual studio (Programs and features: Modify "Visual Studio 2015"), then under Programming Languages->VC++, make sure it's ticked.

Visual Studio Installer

strpeter
  • 2,562
  • 3
  • 27
  • 48
davidsheldon
  • 38,365
  • 4
  • 27
  • 28
  • 1
    I thought I must have had C++ installed and went through a few other solutions before giving up and trying this. Realized that when I originally installed Visual Studio it was for C# and the android emulator. I'd left C++ off to save disk space. So my $0.02 to others is not to dismiss this out of hand. – LetMyPeopleCode Feb 07 '17 at 19:34
9
  1. Run pip install wheel
  2. Download lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml, if your python version is 3.5 , download lxml-3.6.4-cp35-cp35m-win32.whl.
  3. Run python -m pip install lxml-3.6.4-cp35-cp35m-win32.whl
Marcs
  • 3,768
  • 5
  • 33
  • 42
Chris Leung
  • 99
  • 1
  • 2
6

As an update to the answer from @davidsheldon above, if you want to use Visual Studio Build Tools 2017 instead of 2015, it will work.

I found that the default install of the build tools stand alone was not enough, however, I added `VC++ 2015.3 ... toolset for desktop (x86,x64) and then python was happy:

Screenshot showing the installation screen for Visual Studio 2017

Eric G
  • 907
  • 1
  • 9
  • 30
  • Thanks for the screenshot, that was very helpful! In Visual Studio 2019 Build Tools, the package is called "MSVC v140 - VS 2015 C++ build tools (v14.00)" – Steven B. Jul 29 '20 at 16:48
2

I've found another solution to get through this: Because I use anaconda python, so I use this code:

conda install -c conda-forge scrapy
VingtCent
  • 1,874
  • 1
  • 9
  • 10
1

I have same question with you! I found a way no need install vs2015,maybe,you just haven't install twisted.http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted .download twisted --version(Twisted‑17.5.0‑cp36‑cp36m‑win_amd64.whl)(maybe win_amd32.whl if 64didn't work),and run : pip PATH + filename

pip install C:\Users\CR\Downloads\Twisted-17.5.0-cp36-cp36m-win_amd64.whl

pip install Scrapy

I just install successful! good luck for you!

my step to insatll scrapy: 1.pip install wheel 2.pip install lxml 3.pip install pyOpenSSL 4.pip install Twisted (fault->do like above) 5.install pywin32 form : https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/ 6.pip Scrapy (succesful)

John Moutafis
  • 22,254
  • 11
  • 68
  • 112
Undo
  • 11
  • 1
0

Had the same problem and noticed that I had installed the 32bit version in a 64bit machine. All I did was uninstall the wrong one and install the right version and it worked fine.

CPhelefu
  • 128
  • 1
  • 5
0

Easiest way to achieve this, can be automated as it doesn't require user input:

python -m pip install https://download.lfd.uci.edu/pythonlibs/archived/lxml-4.9.0-cp311-cp311-win_amd64.whl

This will install the 64-bit version on your machine.

Clara
  • 65
  • 1
  • 8
-2

First:

pip install wheel

Second: go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml and download proper wheel.

pip install the file you downloaded (.whl).

phd
  • 82,685
  • 13
  • 120
  • 165