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

Error Microsoft Visual C++ 14.0 is required while installing lxml through pip in Python is an error which usually happens when you do not have a C++ compiler installed.

In this Blog Post I am going to explain what happens when you get this error and why it is occurring in the first place then I am going to show you how you can solve it with an easy solution, we will also explore some alternative solutions which can solve the issue at hand.

Explaining the Error Microsoft Visual C++ 14.0 is required while installing lxml through pip in Python

The error can happen to anyone running Microsoft Visual Studios, here is an example of the 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
=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
                                                                       #

You can reproduce the error by using pip in order to install lxml.

By running the command bellow for example.

                                                                       #
pip install lxml
                                                                       #

As a fellow developer and mere mortal, bellow I will make my best attempt at solving the error and give you multiple solutions.

Solution 1 : Install VC++

First, we should understand that Microsoft Visual Studios does not have a built-in C++ compiler.

Please try following these steps and see if this solution solves your problem.

  • Open Microsoft Visual Studios and navigate to Programs and features.
  • Go under features.
  • Go under Programming Languages
  • Find VC++ and check the corresponding box.

Now, restart VS or even your computer and see if this fix worked, this is easy since you do not need to run any particular command.

Solution 2 : Use Conda Instead

Another solution, by the way this could work if you have anaconda with Python.

is to run the following command for example

                                                                       #
conda install -c conda-forge Selenium 
                                                                       #

By the way you should replace selenium here with the package, framework or library of your choice, this is just an example, maybe you need scrapy, so you need to run the following command.

                                                                      #
conda install -c conda-forge scrapy
                                                                      #

This weird error is always confusing. But once you understand why it is happening, it is easy to solve.

Summing-up

That’s it developers and brothers, this is the end of our detailed guide, I hope you found this Blog Post useful in solving the error

If you have the means and want to help, please support our work on our Kofi account, you do not have to.

Thanks, keep coding, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/