343

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Umanda
  • 4,737
  • 3
  • 23
  • 28
  • 9
    make sure to upgrade setuptools: `pip install --upgrade setuptools` see https://wiki.python.org/moin/WindowsCompilers – 3pitt May 29 '18 at 18:35
  • 142
    Use this link to download [Visual C++ 2015 Build Tools](http://go.microsoft.com/fwlink/?LinkId=691126&fixForIE=.exe.). It will install Visual C++ 14.0 without installing Visual Studio. After the installation completes, retry pip install and you won't get the error again. – Lalit Kumar B Aug 29 '18 at 08:42
  • 16
    *sigh* it doesn't end here. Channels doesn't work either. My respect for python is dying quickly! – Ralph Ritoch Oct 25 '18 at 14:52
  • 13
    Save yourself lots of time and hard drive space and go to this answer first: https://stackoverflow.com/a/51087608/84162 – MECU Dec 30 '18 at 02:07
  • 6
    Not working for me, I tried all the answer. I am trying to install scrapy, or should I call it crappy. Nothing really works on first try, does it... – samayo Jan 17 '19 at 00:27
  • 3
    @LalitKumarB I know it is against the rules.. but THANK YOU for that link. I always find the microsoft download pages so confusing, but this simple link took all of that away for me. – zwep Apr 18 '19 at 08:24
  • 2
    Visual C++ Build tools link is 3Gb for me. – rishi jain Jul 15 '19 at 14:54
  • @LalitKumarB It still requires 4GB in all drives. I just installed `Visual C++ 14.2` by downloading it from Microsoft's websites but it didn't work for me. I think i need to reset the PC so I can install built tools. – Zeeshan Ahmad Khalil Sep 09 '19 at 05:31
  • @zwep Glad it helped. And thanks for sharing your feedback, it helps everyone a lot to know which answer/post/comment is most reliable. – Lalit Kumar B Jan 16 '20 at 19:31
  • @ZeeshanAhmadKhalil What was the error you saw? It would be more helpful if you could post more details about what didn't work for you. It's the same way I figured out the appropriate solution, I had to nail down to the root cause and then come with the best solution. – Lalit Kumar B Jan 16 '20 at 19:33
  • I solved this by removing Python and working with Groovy instead. Python needs a v4. – MushyPeas Mar 30 '20 at 15:39
  • @LalitKumarB link doesn't work – alramdein Nov 07 '20 at 04:24
  • @AlifRamdani Link works absolutely fine, it downloads `visualcppbuildtools_full.exe` file – Lalit Kumar B Nov 07 '20 at 16:14
  • For me this method worked, file.bat with these lines: ``` call \VC\Auxiliary\Build\vcvars64.bat SET DISTUTILS_USE_SDK=1 SET MSSdk=1 pip install ``` – Oleg Butko May 15 '21 at 12:52
  • @OlegButko Can you please share the steps in more details. – Irfan Harun Jan 20 '22 at 16:52
  • @IrfanHarun https://snippet.host/tgcu – Oleg Butko Jan 21 '22 at 12:54
  • I keep seeing questions about this, and it's always the same version. Why do so many popular packages apparently want to build with the same specific version of Visual Studio, which is several years old? – Karl Knechtel Feb 02 '22 at 06:00

36 Answers36

193

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 LanguagesC++ 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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
davidsheldon
  • 38,365
  • 4
  • 27
  • 28
  • 55
    After doing this, I still had this error. Upgrading `setuptools` from `28.8.0` to `36.2.7` did the trick. – NauticalMile Aug 03 '17 at 20:04
  • 1
    This post also gives additional information on the required visual C++ build tools: https://www.scivision.co/python-windows-visual-c++-14-required/ – Kobby Kan Mar 22 '18 at 17:43
  • 1
    @davidsheldon, where exactly should I tick the box for Languages->C++? – bmello Jul 04 '18 at 14:25
  • 1
    `pip install --upgrade setuptool` didn't work for me, but `python -m pip install --upgrade setuptool` did – Fire Aug 07 '18 at 16:50
  • 1
    The most important thing to do is the UPGRADE SETUPTOOLS bit – nesdis Sep 15 '18 at 07:58
  • 5
    for me upgrade tools didn't help ;( – rishi jain May 16 '19 at 09:52
  • 11
    I don't understand. It only requires `Visual C++ 14` then why we have to install whole Visual Studio? – Zeeshan Ahmad Khalil Sep 09 '19 at 05:33
  • Are you running these `pip` commands in visual studio (which seems like it is powershell)? Or are you running them in conda. I tried both. Conda gave me the same error, and visual studio doesn't recognize `conda` or `pip` commands – mikey Nov 09 '20 at 20:35
  • @NauticalMile you are the MAN bro! your comment should have been the accepted answer. Almost banging my head against a wall to figure out why installing the latest VS C++ build tools (for VS Studio 2019) wasn't working, despite it being a newer version. Turns out the `pip install -U setuptools` was the trick. – rv.kvetch Aug 02 '21 at 17:14
  • But [Fire said](https://stackoverflow.com/questions/29846087/error-microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat#comment90424430_40888720) that `pip install --upgrade setuptool` ***didn't*** work(?). Whereas this did: `python -m pip install --upgrade setuptool`. Was it different for you? What is the explanation? – Peter Mortensen Jan 16 '22 at 13:20
166

Binary install it the simple way!

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alastair McCormack
  • 26,573
  • 8
  • 77
  • 100
119

To solve any of the following errors:

  • Failed building wheel for misaka
  • Failed to build misaka
  • Microsoft Visual C++ 14.0 is required
  • Unable to find vcvarsall.bat

The solution is:

  1. Go to Build Tools for Visual Studio 2017

  2. Select free download under Visual Studio Community 2017. This will download the installer. Run the installer.

  3. 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).

  4. In cmd, type pip3 install misaka.

    Enter image description here

    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.

    Screenshot of Modify button

    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

    The modules you need for c++ compiler

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
WISAM
  • 1,870
  • 1
  • 12
  • 16
  • 4
    I am not getting the option for Python development under Web & Cloud. Would it work if I left it blank? – crucifix94 Jun 07 '18 at 13:20
  • 2
    most important thing is to check Desktop development with C++ ...it will work – WISAM Jun 09 '18 at 11:28
  • This worked and I didn't need the Build Tools for VS2015 either. – xji Jul 26 '18 at 21:17
  • added an edit to show the minimum required packages for most installations – studioj Aug 28 '18 at 09:29
  • I am still getting an error when attempting to install on windows: fatal error C1083: Cannot open include file: 'io.h': No such file or directory – mamafoku Sep 24 '18 at 19:20
  • For "Microsoft Visual C++ 14.0 is required" error I clicked on the 2017 installation's modify button, chose only "SDK 10.." and "VC++ 2015.3 v14.00 (v140) toolset for desktop" (lower at the bottom). You might have to copy a couple of files as in: https://stackoverflow.com/questions/14372706/visual-studio-cant-build-due-to-rc-exe if you see a LINK error. – Anon Sep 26 '18 at 12:10
  • Why would you need misaka? – Bram Vanroy Dec 21 '18 at 10:33
  • @Bram Vanroy Hi thanks for asking ..it is simply for something called link embedding.... same technique used here to mark a text as code or link or bold.... so for example lets say I have a Post model and inside this I have a record called comment, when I use misaka if I enter _ italic word _ inside this field then _italic word_ will be displayed (without underscore) .same if I use ** bold ** then **bold** will be displayed .same with ` any code ` then `anycode` will be displayed . hope this helps – WISAM Dec 21 '18 at 19:11
  • Can we install without downloading whole Visual Studio? – Prathamesh More Dec 30 '18 at 14:11
  • @Prathamesh More ,you can try other solutions as using the binary-only option for pip. Other solutions will work to solve some errors.you will still have errors here and there if you don't install the package. its totally up to you.thanks – WISAM Jan 02 '19 at 21:35
  • 1
    This is the only thing that worked for me! Installing Microsoft Visual C++ 14.0 did not help and setup tools were up to date, but I still got the error "Microsoft Visual C++ 14.0 is required" until I installed Visual Studio. – Tigerware Mar 26 '19 at 17:00
  • How much bandwidth it needs? It states that Total Space required is 4.5GB – Smart Manoj Jun 21 '19 at 07:29
  • @SmartManoj this will depend on your internet speed. – WISAM Aug 05 '19 at 03:19
  • Total amount of data ? – Smart Manoj Aug 05 '19 at 04:14
81

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • 5
    Thanks. I believe `pip wheel` creates a wheel archive; and, `pip install` actually installs the specified wheel file. See https://pip.pypa.io/en/stable/reference/pip_wheel. Btw, this approach worked for me in installing `hmmlearn` package via `hmmlearn-0.2.1-cp36-cp36m-win_amd64.whl` wheel. – Oleg Melnikov Sep 14 '17 at 18:29
  • On one of my computers, downloaded a wheel let me get around installing MS Visual C++ 14. But like Oleg said, use `pip install`, not `pip wheel`. – Benny Jobigan Sep 27 '17 at 14:13
  • @OlegMelnikov @ BennyJobigan Thanks for the correction, I amended the answer accordingly. – Franck Dernoncourt Sep 27 '17 at 18:26
  • 1
    thank you for this BTW. this solved my problem with Twisted. I really didn't wanna download 3 GB of data just to use one thing! aha. – Mangohero1 Jan 19 '18 at 03:45
  • 1
    Could someone please explain why/how this works? It worked for me, I'm just curious what exactly the compiled binary is for – davidtgq Mar 19 '18 at 04:48
  • 2
    This is best solution here. Rather than going for monolithic visual studio, i opted this. If u need any package u can also search it on 'https://pypi.org/'. Just remember to append wheel with name. e.g 'python-Levenshtein wheels' – Manjeet Mar 02 '19 at 15:48
  • Use pipwin module – Smart Manoj Jun 21 '19 at 07:17
  • 1
    @FranckDernoncourt I want to install the `eth-tester` python package. But I can't figure out that which precompiled binary I should download!. I think precompiled binary of that package is not available there – Zeeshan Ahmad Khalil Sep 09 '19 at 05:22
  • Well, good as a quick solution but if you later want to install something which doesn't have a precompiled binary, you will anyway have to go through all of this again. It's usually a better idea to hit at the root of the cause than just delaying it. +1 otherwise. – Fr0zenFyr Mar 12 '20 at 05:17
  • 1
    save my life while i wanna install python-geohash which vc++ 14.0 is required – carton.swing Jan 25 '21 at 03:13
  • It seems there isn't a compatible binary for python 3.10 yet – 101is5 Nov 11 '21 at 13:48
62

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:

  1. Download the latest (the last one) wheel file from this link: wheel file for twisted package

    Enter image description here

  2. I'd recommend saving that wheel file in the directory where you've installed Python, i.e., somewhere on the local disk C:

  3. Then visit the folder where the wheel file exists and run pip install <*wheel file's name*>

  4. 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sushant Rajbanshi
  • 1,985
  • 1
  • 19
  • 20
  • Worked like a charm for me too -- and there's a good chance that your solution will work for any package "requiring" Windows C++ as long as you can find the properly compiled whl for it... If anyone finds this hypothesis incorrect -- please let us know. – JxAxMxIxN Jan 19 '18 at 18:31
  • 20
    Do not use the latest twisted, use that one which match your python version i.e. for python3.6 use twisted with cp36 – Sojtin Mar 09 '18 at 16:34
  • Adding to this, if you are using a virtualenv, download the above file into the Lib\site-packages folder and install using pip while virtualenv is active. – Arindam Roychowdhury Aug 30 '18 at 06:15
  • 2
    This is how it goes... May I add "cp..." indicates your Python version and "win..." your system 32 vs. 64 bit. So you can check in the cdm window what your Python version is `python --version` and pic the right whl-file – Peter Nov 18 '18 at 17:16
  • https://stackoverflow.com/review/suggested-edits/21928251 **NOTE for windows users:** after step 3, close the existing CMD or any terminal you are using and again open/start a new/fresh terminal to execute the command `pip install Scrapy` otherwise you may get the same error which you are getting previously while executing `pip install Scrapy`. – Evandro Coan Jan 15 '19 at 14:02
  • Use pipwin module – Smart Manoj Jun 21 '19 at 07:17
  • thanks. I have tried many solutions, and only this works. – Xin Nov 14 '20 at 14:52
  • This was the answer for me. I tried all the other fixes, but this was the issue. Thanks! – ProfessorFluffy Jan 24 '21 at 02:43
31

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.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alejandro Alcalde
  • 5,990
  • 6
  • 39
  • 79
  • 2
    Thank you! I got the Build Tools for Visual Studio 2017 [here](https://download.visualstudio.microsoft.com/download/pr/3e542575-929e-4297-b6c6-bef34d0ee648/639c868e1219c651793aff537a1d3b77/vs_buildtools.exe) – Guillaume F. Aug 23 '20 at 02:02
  • 1
    Thanks for the link to the 2017 build tool! It finally worked for me after installing that and uninstalling the previous one. – Barnacle Own Sep 12 '22 at 01:28
22

I had this exact issue while trying to install mayavi.

I also had the common error: Microsoft Visual C++ 14.0 is required when pip installing a library.

Example of Error

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.

  1. 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

    • If you have already installed this, skip to 2.

      Installing Build Tools

  2. Select the C++ components you require (I didn't know which I required, so I installed many of them).

    • If you have already installed Build Tools for Visual Studio 2017 then open the application Visual Studio Installer then go to Visual Studio Build Tools 2017ModifyIndividual Components and selected the required components.
    • From other answers, important components appear to be: C++/CLI support, VC++ 2017 version <...> latest, Visual C++ 2017 Redistributable Update, Visual C++ tools for CMake, Windows 10 SDK <...> for Desktop C++, Visual C++ Build Tools core features, Visual Studio C++ core features.

    Select Components

  3. Install/Modify these components for Visual Studio Build Tools 2017.

  4. This is the important step. Open the application Visual Studio Installer then go to Visual Studio Build ToolsLaunch. Which will open a CMD window at the correct location for Microsoft Visual Studio\YYYY\BuildTools.

    Open Visual Studio Installer

    Launch Visual Studio Build Tools

    CMD Build Tools Window

  5. Now enter python -m pip install --upgrade setuptools within this CMD window.

    CMD Update Setuptools

  6. Finally, in this same CMD window, pip install your Python library: pip install -U <library>.

    CMD Install Python Library

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Aldahunter
  • 618
  • 1
  • 6
  • 12
  • If you get errors about unresolved symbols, make sure you opened the right command prompt for your environment. If you need the 64 bit developer tools you might have to open the command prompt from the windows start menu. – Dawied Jun 30 '23 at 15:53
17

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
15

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++

TOZX
  • 181
  • 1
  • 8
  • 1
    Hi, and welcome to Stack Overflow! Your answer seems a bit incomplete — what does `pipwin` do and why is it better than `pip`? – Chris Warrick Apr 12 '21 at 22:13
13

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
CyberPlayerOne
  • 3,078
  • 5
  • 30
  • 51
13

I had this same problem. A solution for updating setuptools

pip install -U setuptools

or

pip install setuptools --upgrade
vvvvv
  • 25,404
  • 19
  • 49
  • 81
user3661384
  • 524
  • 7
  • 18
13

Make sure that you've installed these required packages. It worked perfectly in my case as I installed the checked packages:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dikshit Kathuria
  • 1,182
  • 12
  • 15
  • 4
    Thank you very much for this answer. was missing C++/CLI support and VC++ 2015.3...; adding those fixed all my issues – spinodal Feb 19 '19 at 03:54
11

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Xantium
  • 11,201
  • 10
  • 62
  • 89
  • It's rather sad that Python needs to use another language platform's compiler to do its grunt work. Why did the python team not build their own compiler with just the bare bones of what is needed. – Andrew S Aug 15 '18 at 20:02
  • @AndrewS Yes it's sad but nessesary. Developing an efficient C compiler is no easy feat (like developing a new language). Especially cross platform (Windows insits on it's own non-standard system), so it is really impossible to expect that. C++ is even worse because it is much more complex (even during the develpment of the MS compiler for C++ there were massive problems getting support for all the syntax; hence the stdafx.h header to include the nessesary features). Doing this would mean using HUGE amounts of development time to reinvent the wheel. – Xantium Aug 15 '18 at 21:38
  • @AndrewS as well as almost double the development time to even maintain both projects ultimately slowing down each release of Python itself. Building off the already existing MS compiler is much easier (as they do not need to develop it). – Xantium Aug 15 '18 at 21:48
9

Use the link to Visual C++ 2015 Build Tools. That will install Visual C++ 14.0 without installing Visual Studio.

S.Rumeshi
  • 251
  • 2
  • 6
6

I had the same issue. Downloading the Build Tools for Visual Studio 2017 worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ocean800
  • 3,489
  • 13
  • 41
  • 73
6

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
New2coding
  • 715
  • 11
  • 23
5

Just go to https://www.lfd.uci.edu/~gohlke/pythonlibs/ find your suitable package (whl file). Download it. Go to the download folder in cmd or typing 'cmd' on the address bar of the folder. Run the command :

pip install mysqlclient-1.4.6-cp38-cp38-win32.whl

(Type the file name correctly. I have given an example only). Your problem will be solved without installing build toll cpp of 6GB size.

  • I was having a problem with the setproctitle package, tried associated wheel file. It says, "wheelname" is not a supported wheel in this platform. – Shamsul Arefin Jul 10 '20 at 08:34
4

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.

  1. Download lxml‑4.2.3‑cp37‑cp37m‑win_amd64.whl from Lxml
  2. put it in folder where Python is installed
  3. install it using pip install <file-name>

Now you can run pip install scrapy.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vishal Patel
  • 554
  • 6
  • 15
3

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:

  1. Uninstall any versions of Visual Studio you have had, through Control Panel
  2. Install Visual Studio 2015 and chose the default option that will install Visual C++ 14.0 on its own
  3. You can use PyCharm for installing Scrapy: Menu ProjectProject Interpreter+ (install Scrapy)
  4. Check Scrapy in the REPL and PyCharm by import. You should not see any errors.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sandeep Anand
  • 426
  • 7
  • 13
  • Also Not required to use Conda/pip for this , just the above solved my issues . – Sandeep Anand May 04 '17 at 06:28
  • If you already have visual studio 2015 (any version including community) installed you don't need to uninstall it, just go to programs & features and modify the installation, tick on the programming languages - Visual C++ as per this https://stackoverflow.com/a/40886619/1335793 – Davos Sep 21 '17 at 08:19
3

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yonti
  • 1,179
  • 9
  • 8
3

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vyrnach
  • 119
  • 1
  • 9
3

I had the same exact issue on my windows 10 python version 3.8. In my case, I needed to install mysqlclient were the error occurred Microsoft Visual C++ 14.0 is required. Because installing visual studio and it's packages could be a tedious process, Here's what I did:

step 1 - Go to unofficial python binaries from any browser and open its website.

step 2 - press ctrl+F and type whatever you want. In my case it was mysqlclient.

step 3 - Go into it and choose according to your python version and windows system. In my case it was mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl and download it.

here

step 4 - open command prompt and specify the path where you downloaded your file. In my case it was C:\Users\user\Downloads

step 5 - type pip install .\mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl and press enter.

Thus it was installed successfully, after which I went my project terminal re-entered the required command. This solved my problem

Note that, while working on the project in pycharm, I also tried installing mysql-client from the project interpreter. But mysql-client and mysqlclient are different things. I have no idea why and it did not work.

2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sneha
  • 140
  • 6
2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
XavierBrt
  • 1,179
  • 8
  • 13
2

This works for me:
pip install --only-binary :all: mysqlclient

jps
  • 20,041
  • 15
  • 75
  • 79
2

If Visual Studio is NOT your thing, and instead you are using VS Code, then this link will guide you thru the installer to get C++ running on your Windows.

You only needs to complete the Pre-Requisites part. https://code.visualstudio.com/docs/cpp/config-msvc/#_prerequisites

This is similar with other answers, but this link will probably age better than some of the responses here.

PS: don't forget to run pip install --upgrade setuptools

  • I have asked a new question whether Visual C++ (4.5 GB) can be imitated by MinGW which costs just 450 MB, see https://stackoverflow.com/questions/62149329/imitate-visual-c-with-mingw-for-python-packages-based-on-visual-c – questionto42 Jun 02 '20 at 12:42
  • **Wow!** Save 4GB in the install process would be an amazing accomplishment. I hope you can get it sorted @Lorenz. I will definitely keep an eye on your question. – Paulo Silva Jun 05 '20 at 19:27
2

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.

werner
  • 377
  • 2
  • 10
1

I had the same problem. I needed a 64-bit version of Python so I installed 3.5.0 (the most recent as of writing this). After switching to 3.4.3 all of my module installations worked.

Python Releases for Windows

David Braun
  • 782
  • 1
  • 9
  • 18
1

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:

  1. Directly in base Python
  2. In virtual environments and PyCharm

Also check:

filename.whl is not supported wheel on this platform

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shashank Singh
  • 647
  • 1
  • 5
  • 22
1

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zhong Ri
  • 2,556
  • 1
  • 19
  • 23
  • What is *"Desktop with C++ and Python"*? Can you provide a link and/or a screenshot for some context? Or the equivalent? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/57314348/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Jan 16 '22 at 17:39
1

I had the same issue while installing mysqlclient for the Django project.

In my case, it's the system architecture mismatch causing the issue. I have Windows 7 64bit version on my system. But, I had installed Python 3.7.2 32 bit version by mistake.

So, I re-installed Python interpreter (64bit) and ran the command

pip install mysqlclient

I hope this would work with other Python packages as well.

Shashanth
  • 4,995
  • 7
  • 41
  • 51
1

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.

BlueLightning42
  • 344
  • 4
  • 15
0

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.

Jimmy Chen
  • 305
  • 2
  • 11
0

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.

carton.swing
  • 1,517
  • 17
  • 12
0
  1. First you'll need to download the visual studio build tools from https://visualstudio.microsoft.com/downloads#other
  2. Rename the file vs_buildtools.exe (not required but you'll have to modify the script below)
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

visch
  • 707
  • 5
  • 23
0

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>
Dan
  • 151
  • 6