Reputation: 4843
I've installed Python 3.5 and while running
pip install mysql-python
it gives me the following error
error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
I have added the following lines to my Path
C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;
C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
I have a 64-bit Windows 7 setup on my PC.
What could be the solution for mitigating this error and installing the modules correctly via pip
.
Upvotes: 344
Views: 1179309
Reputation: 151
I already had a version of VC++ that was v14+, but was encountering the issues due to Anaconda. Ultimately, the following worked for me instead of using pip, pipwin, or a wheel file.
conda install <package_name_here>
Upvotes: 0
Reputation: 775
start-process -wait -filepath vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools `
--add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 `
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
--add Microsoft.VisualStudio.Component.Windows10SDK `
--add Microsoft.VisualStudio.Component.VC.CoreIde `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.VC.14.29.16.11.CLI.Support `
--add Microsoft.VisualStudio.ComponentGroup.UWP.VC.v142'
I created a seperate question and answer here for windows docker users Microsoft Visual C++ 14.0 is Required, installing pip package on Windows Docker
Upvotes: 0
Reputation: 658
mayavi
.I also had the common error: Microsoft Visual C++ 14.0 is required when pip installing a library.
After looking across many web pages and the solutions to this question, with none of them working, I figured out these steps (most taken from previous solutions) allowed this to work.
Go to Build Tools for Visual Studio 2017 and install Build Tools for Visual Studio 2017. Which is under All downloads (scroll down) → Tools for Visual Studio 2017
Select the C++ components you require (I didn't know which I required, so I installed many of them).
Install/Modify these components for Visual Studio Build Tools 2017.
This is the important step. Open the application Visual Studio Installer then go to Visual Studio Build Tools → Launch. Which will open a CMD window at the correct location for Microsoft Visual Studio\YYYY\BuildTools.
Now enter python -m pip install --upgrade setuptools
within this CMD window.
Finally, in this same CMD window, pip install your Python library: pip install -U <library>
.
Upvotes: 23
Reputation: 49112
Use this link to download and install Visual C++ 2015 Build Tools. It will automatically download visualcppbuildtools_full.exe
and install Visual C++ 14.0 without actually installing Visual Studio.
After the installation completes, retry pip install
and you won't get the error again.
I have tested it on the following platforms and versions:
Python 3.6 on Windows 7 64-bit
Python 3.8 on Windows 10 64-bit
Upvotes: 17
Reputation: 2724
For Python 3.7.4, the following set of commands worked: Before those commands, you need to confirm that Desktop with C++ and Python is installed in Visual Studio.
cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvarsall.bat x86_amd64
cd \
set CL=-FI"%VCINSTALLDIR%\tools\msvc\14.16.27023\include\stdint.h"
pip install pycrypto
Upvotes: 1
Reputation: 1249
Look if the package has an official fork that include the necessary binary wheels.
I needed the package python-Levenshtein
, had this error, and found the package python-Levenshtein-wheels
instead.
Upvotes: 2
Reputation: 6220
After reading a lot of answers on Stack Overflow and none of them working, I finally managed to solve it following the steps in this question. I will leave the steps here in case the page disappears:
Please try to install Build Tools for Visual Studio 2017, select the workload “Visual C++ build tools” and check the options "C++/CLI support" and "VC++ 2015.3 v14.00 (v140) toolset for desktop" as below.
Upvotes: 34
Reputation: 1312
Make sure that you've installed these required packages. It worked perfectly in my case as I installed the checked packages:
Upvotes: 13
Reputation: 129
None of the solutions here and elsewhere worked for me. It turns out an incompatible 32-bit version of mysqlclient is being installed on my 64-bit Windows 10 OS because I'm using a 32-bit version of Python.
I had to uninstall my current Python 3.7 32 bit, and reinstalled Python 3.7 64 bit and everything is working fine now.
Upvotes: 3
Reputation: 717
I had exactly the same issue and solved it by installing mysql-connector-python with:
pip install mysql-connector-python
I am on Python 3.7 and Windows 10 and installing Microsoft Build Tools for Visual Studio 2017 (as described here) did not solve my problem that was identical to yours.
Upvotes: 6
Reputation: 584
To add on top of Sushant Chaudhary's answer:
In my case, I got another error regarding lxml as below:
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-3.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
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 had to install lxml‑4.2.3‑cp37‑cp37m‑win_amd64.whl the same way as in the answer of Sushant Chaudhary to successfully complete installation of Scrapy.
pip install <file-name>
Now you can run pip install scrapy
.
Upvotes: 4
Reputation: 27744
Use the binary-only option for pip. For example, for mysqlclient:
pip install --only-binary :all: mysqlclient
Many packages don't create a build for every single release which forces your pip to build from source. If you're happy to use the latest pre-compiled binary version, use --only-binary :all:
to allow pip to use an older binary version.
Upvotes: 172
Reputation: 1920
To solve any of the following errors:
The solution is:
Select free download under Visual Studio Community 2017. This will download the installer. Run the installer.
Select what you need under workload tab:
a. Under Windows, there are three choices. Only check Desktop development with C++.
b. Under Web & Cloud, there are seven choices. Only check Python development (I believe this is optional, but I have done it).
In cmd, type pip3 install misaka
.
Note if you already installed Visual Studio then when you run the installer, you can modify yours (click modify button under Visual Studio Community 2017) and do steps 3 and 4.
Final note: If you don't want to install all modules, having the three below (or a newer version of the VC++ 2017) would be sufficient. (You can also install the Visual Studio Build Tools with only these options, so you don’t need to install Visual Studio Community Edition itself) => This minimal install is already a 4.5 GB, so saving off anything is helpful
Upvotes: 121
Reputation: 11603
To expand on the answers by ocean800, davidsheldon and user3661384:
You should now no longer use Visual Studio Tools 2015 since a newer version is available. As indicated by the Python documentation, you should be using Visual Studio Tools 2017 instead.
Visual C++ Build Tools 2015 was upgraded by Microsoft to Build Tools for Visual Studio 2017.
Download it from here.
You will also require setuptools
. If you don't have setup tools, run:
pip install setuptools
Or if you already have it, be sure to upgrade it.
pip install setuptools --upgrade
For the Python documentation link above you will see that setuptools version must be at least 34.4.0 for Visual Studio Tools to work.
Upvotes: 11
Reputation: 657
Oops! Looks like they don't have Windows wheels on PyPI.
In the meantime, installing from source probably works or try downloading MSVC++ 14 as suggested in the error message and by others on this page.
Christoph's site also has unofficial Windows binaries for Python extension packages (.whl files).
Follow the steps mentioned in the following links to install binaries:
Also check:
filename.whl is not supported wheel on this platform
Upvotes: 1
Reputation: 140
I was facing the same problem. The following worked for me:
Download the unofficial binaries file from Christoph Gohlke installers site as per the Python version installed on your system.
Navigate to the folder where you have installed the file and run
pip install filename
For me python_ldap‑3.0.0‑cp35‑cp35m‑win_amd64.whl
worked as my machine is 64 bit and Python version is 3.5.
This successfully installed python-ldap on my Windows machine. You can try the same for mysql-python.
Upvotes: 2
Reputation: 2010
I had the exact issue while trying to install the Scrapy web scraping Python framework on my Windows 10 machine. I figured out the solution this way:
Download the latest (the last one) wheel file from this link: wheel file for twisted package
I'd recommend saving that wheel file in the directory where you've installed Python, i.e., somewhere on the local disk C:
Then visit the folder where the wheel file exists and run pip install <*wheel file's name*>
Finally, run the command pip install Scrapy
again and you're good to use Scrapy or any other tool which required you to download a massive Windows C++ Package/SDK.
Disclaimer: This solution worked for me while trying to install Scrapy, but I can't guarantee the same happening while installing other software, packages, etc.
Upvotes: 62
Reputation: 3737
I had the same issue. Downloading the Build Tools for Visual Studio 2017 worked for me.
Upvotes: 6
Reputation: 3170
I had the same problem when installing the spaCy module. And I checked the control panel, and I had several Microsoft Visual C++ redistributables installed already.
I selected "Microsoft Visual Studio Community 2015" which was already installed on my PC → "Modify" → check "Common Tools for Visual C++ 2015". Then it will take some time and download more than 1 GB to install it.
This fixed my issue. Now I have spaCy installed.
Upvotes: 12
Reputation: 83427
As the other responses point out, one solution is to install Visual Studio 2015. However, it takes a few GBs of disk space.
One way around is to install precompiled binaries. The webpage Unofficial Windows Binaries for Python Extension Packages (mirror) contains precompiled binaries for many Python packages. After downloading the package of interest to you, you can install it using pip install
, e.g. pip install mysqlclient‑1.3.10‑cp35‑cp35m‑win_amd64.whl
.
Upvotes: 81
Reputation: 436
I just had the same issue while using the latest Python 3.6. With Windows OS 10 Home Edition and a 64-bit operating system.
Steps to solve this issue:
Upvotes: 3
Reputation: 40085
Your path only lists Visual Studio 11 and 12, it wants 14, which is Visual Studio 2015. If you install that, and remember to tick the box for Languages → C++ then it should work.
On my Python 3.5 install, the error message was a little more useful, and included the URL to get it from:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
New working link.
As suggested by Fire, you may also need to upgrade setuptools
package for the error to disappear:
pip install --upgrade setuptools
Upvotes: 195
Reputation: 1489
I had a similar situation installing pymssql.
pip was trying to build the package, because there were no official wheels for Python 3.6 and Windows.
I solved it by downloading an unofficial wheel from Unofficial Windows Binaries for Python Extension Packages.
Specifically for your case: MySQL-python
Upvotes: 3
Reputation: 544
I had this same problem. A solution for updating setuptools
pip install -U setuptools
or
pip install setuptools --upgrade
Upvotes: 14
Reputation: 386
I tried ALL of the above and none worked. Just before before signing up for the booby hatch, I found another reason for the error : using the wrong shell on Windows.
conda init cmd.exe
did the trick for me. Hope it may save someone else, too.
Upvotes: 2
Reputation: 181
Use this and save time
pip install pipwin
pipwin install yourLibrary
pipwin is like pip, but it installs precompiled Windows binaries provided by Christoph Gohlke. Saves you a lot of time googling and downloading.
And in this case pipwin will solve the problem
Error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
Read more about pipwin and here they mention Microsoft Visual C++
Upvotes: 15
Reputation: 1727
Following the official installation guide for Windows C++ compilers:
https://wiki.python.org/moin/WindowsCompilers
to upgrade setuptools and install specific Microsoft Visual C++ compiler.
It has already contains some points refered in other answer.
Upvotes: 0
Reputation: 76
This works for me:
pip install --only-binary :all: mysqlclient
Upvotes: 2
Reputation: 315
If you have already installed Visual Studio Build Tools (as in other comments), and upgraded setuptools but it still doesn't work:
Make sure to run pip under x86 or x64 Native Tools Command Prompt.
It can be found under VS folder in Windows start menu. The default command line prompt may NOT provide Pip the path to the VS build tool, as is in my case.
Upvotes: 0
Reputation: 354
TLDR run vcvars64.bat
After endlessly searching through similar questions with none of the solutions working. -Adding endless folders to my path and removing them. uninstalling and reinstalling visual studio commmunity and build tools. and step by step attempting to debug I finally found a solution that worked for me.
(background notes if anyone is in a similar situation)
I recently reset my main computer and after reinstalling the newest version of python (Python3.9) libraries I used to install with no troubles (main example pip install opencv-python
) gave
cl
is not a full path and was not found in the PATH.
after adding cl to the path from
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64
and several different windows kits one at a time getting the following.
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
with various link errors or " Run Build Command(s):jom /nologo cmTC_7c75e\fast && The system cannot find the file specified"
upgrading setuptools and wheel from both a regular command line and an admin one did nothing as well as trying to manually download a wheel or trying to install with --only-binary :all:
Finally the end result that worked for me was running the correct vcvars.bat for my python installation namely running
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
once (not vcvarsall or vcvars32) (because my python installed was 64 bit) and then running the regular command pip install opencv-python
worked.
Upvotes: 1