Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while installing lxml through pip: Microsoft Visual C++ 14.0 is required

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.

like image 711
Zeokav Avatar asked Aug 15 '16 04:08

Zeokav


People also ask

How do I know if I have Visual C++?

To check if Visual C++ redistributables are installed, open Add and Remove Programs and look for the Microsoft Visual C++ Redistributable. If installed, you see "Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.22.

Is Microsoft Visual C++ required?

These libraries are required by many applications built by using Microsoft C and C++ tools. If your app uses those libraries, a Microsoft Visual C++ Redistributable package must be installed on the target system before you install your app.


3 Answers

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

like image 107
davidsheldon Avatar answered Oct 16 '22 14:10

davidsheldon


  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
like image 8
Chris Leung Avatar answered Oct 16 '22 12:10

Chris Leung


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

like image 6
Eric G Avatar answered Oct 16 '22 12:10

Eric G