118

I just ran the following command:

pip install -U steem

and the installation worked well until it failed to install pycrypto. Afterwards I did the

pip install cryptography

command because I thought it was the missing package. So my question is, how I can install steem without the pycrypto-error (or the pycrypto-package in addition) and how to uninstall the cryptography-Package which I don't need. (I'm using Windows 7 and Python 3)

Requirement already up-to-date: python-dateutil in c:\users\***\appdata\lo
cal\programs\python\python36\lib\site-packages (from dateparser->maya->steem)
...
Installing collected packages: urllib3, idna, chardet, certifi, requests, pycryp
to, funcy, w3lib, voluptuous, diff-match-patch, scrypt, prettytable, appdirs, la
ngdetect, ruamel.yaml, humanize, tzlocal, regex, dateparser, pytzdata, pendulum,
maya, ecdsa, pylibscrypt, ujson, toolz, steem
Running setup.py install for pycrypto ... error
Complete output from command c:\users\***\appdata\local\programs\pytho
n\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\
***~1\\AppData\\Local\\Temp\\pip-build-k6flhu5k\\pycrypto\\setup.py';f=getattr(
tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();
exec(compile(code, __file__, 'exec'))" install --record C:\Users\***N~1\AppDat
a\Local\Temp\pip-igpkll6u-record\install-record.txt --single-version-externally-
managed --compile:
running install
running build
running build_py
...
building 'Crypto.Random.OSRNG.winrandom' 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

----------------------------------------
Command "c:\users\***\appdata\local\programs\python\python36\python.exe -u
-c "import setuptools, tokenize;__file__='C:\\Users\\***N~1\\AppData\\Local\\
Temp\\pip-build-k6flhu5k\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(
__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,   __fil
e__, 'exec'))" install --record C:\Users\***N~1\AppData\Local\Temp\pip-igpkll6
u-record\install-record.txt --single-version-externally-managed --compile"   faile
d with error code 1 in C:\Users\***N~1\AppData\Local\Temp\pip-build-    k6flhu5k\p
ycrypto\
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Studentu
  • 1,375
  • 2
  • 10
  • 11
  • 1
    I finally got to solve this issue as described here: https://stackoverflow.com/a/55575792/1612432 – Alejandro Alcalde Apr 08 '19 at 14:35
  • Does this answer your question? [Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)](https://stackoverflow.com/questions/29846087/microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat) – AMC Jan 24 '20 at 17:43
  • For some of you guys the solution is this: https://stackoverflow.com/questions/62808726/the-system-cannot-find-the-path-specified-at-the-beginning-of-cmd/62808833#62808833 – colt.exe May 30 '23 at 22:15

14 Answers14

131

You need to install Microsoft Visual C++ 14.0 to install pycrypto:

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

In the comments you ask which link to use. Use the link to Visual C++ 2015 Build Tools. That will install Visual C++ 14.0 without installing Visual Studio.

Alternate link: https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.2_standalone:_Build_Tools_for_Visual_Studio_2019_.28x86.2C_x64.2C_ARM.2C_ARM64.29

In the comments you ask about methods of installing pycrypto that do not require installing a compiler. The binaries in the links appear to be for earlier versions of Python than you are using. One link is to a binary in a DropBox account.

I do not recommend downloading binary versions of cryptography libraries provided by third parties. The only way to guarantee that you are getting a version of pycrypto that is compatible with your version of Python and has not been built with any backdoors is to build it from the source.

After you have installed Visual C++, just re-run the original command:

pip install -U steem

To find out what the various install options mean, run this command:

pip help install

The help for the -U option says

-U, --upgrade        Upgrade all specified packages to the newest available
                     version. The handling of dependencies depends on the
                     upgrade-strategy used.

If you do not already have the steem library installed, you can run the command without the -U option.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
  • 1
    Thank you for your answer, David! So when I have installed Visual C++, do I have to run the "pip install -U steem"-command again or just some install pycrypto-command-thing? (I'm asking, because I don't want to have the packages that were installed before the error twice on my computer.) – Studentu Jul 06 '17 at 16:56
  • 1
    Running `pip install -U steem` again won't install any packages twice. It will see that some of the dependencies are already installed and skip over them. After that, it will try to install `pycrypto` again and the rest of the installation should complete. –  Jul 06 '17 at 17:01
  • 2
    Thanks, David! I'll try it again as you have discribed. However, I don't know which Microsoft Visual C++ to download from the site in the url above - do I need Visual C++ 2015 or 2017 or do both include the 14.0-version which is required for python? – Studentu Jul 07 '17 at 21:39
  • 1
    In the thread which this one was marked a duplicate of there seems to be another way to install pycrypto without Visual C++. But I'm really new to this stuff and don't get the explanation written there. So how am I supposed to continue in order to be able to install pip -U steem without an error? – Studentu Jul 07 '17 at 21:43
  • Okay, well, thank you so much, David! :) Of course I wanna choose the most secure way to handle the installation. I just have a (hopefully) final question: What did the -U in the install command do? Could I run/have run the installation process also without it? – Studentu Jul 07 '17 at 22:24
  • Hello David, I'm still having trouble with this specific installation. Now Visual seems to work (I installed it from the link you gave me) but now I get a bunch of errors. I'd be glad if you again knew what to do, my question is in this thread: https://stackoverflow.com/questions/45088428/pip-install-u-steem-error-windows-kits – Studentu Jul 13 '17 at 18:29
  • Hi David, a quick question: During the installation of Anaconda I am asked to choose the following both setting options: 1) Add Anaconda to my PATH environment variable. 2) Register Anaconda as my default Python 3.6 There are two short descriptions, too, but I don't exactly understand what they say. I wanna be able to use jetbrains pycharm which I am using currently after installing Anaconda, too, and also wanna stay able to choose on Pycharm between using Python 2.7 and Python 3.6 which I have both installed. (And of course, the steem installation should work when having Anaconda, too.) – Studentu Jul 15 '17 at 14:33
  • And a second thing: As we don't need it for the steem-installation, can I deinstall Visual C++ 2015 Build Tools without damaging anything? (I'd deinstall it via Windows->Systemsteuerung(control panel)->Programme(programs)->Programme und Funktionen(programs and functions) and then rightclicking and choosing deinstalling of Microsoft Visual C++ 2015 Redistributable (x64) as well as Microsoft Visual C++ 2015 Redistributable (x86) and Microsoft Visual C++ 2015 Build Tools, which where all installed two days ago. Is this fine? – Studentu Jul 15 '17 at 15:10
  • Glad to hear you are using PyCharm. It will save you a lot of time. In PyCharm you can [Configure Available Python Interpreters](https://www.jetbrains.com/help/pycharm/configuring-available-python-interpreters.html). Uninstalling Visual C++ should not cause any problems. –  Jul 15 '17 at 21:00
  • Yes, I also like PyCharm very much, thanks for the link to the configuration. Could you just please answer my first question, too, if I should choose the two optional settings in the Anaconda installation or one or neither of them? – Studentu Jul 16 '17 at 00:17
  • Sorry, I don't know enough to tell you what to choose. –  Jul 16 '17 at 00:56
  • 1
    Hello David, I finally found the courage to give the Anaconda installation a try and it works just fine besides my other Python-Versions; Pycharm is handling them very well. But my question now is, how to tell the pip installation command which Python-Version I want to install packages (i.e. the steem-module) to? The solution with typing in the Version-ending (i.e. - 2.7, - 3.6 or pip2, pip3) doesn't work for me, because both my previously installed Python and the Anaconda-Python are the same version (3.6.1). I can start a new thread for this question, if you consider it off-topic. – Studentu Jul 25 '17 at 11:50
  • 1
    Hello, I have a question about this... because I did the same thing (installed Microsoft Visual version 14), and also installed Visual Studio (thought that it could help). However, even after installation over both these things... my pip install qutip still gives this error that I dont have MSVC version 14. However, I do see this MS C++ version 14 in 'installed programs'. So it seems that pip install doesnt know where to look... is this correct? – zwep Sep 25 '17 at 19:58
  • 7
    Finally a link for the VS 14.0 build tools that is still working.... Thanks! Thanks! Thanks! – The Dodo Aug 02 '18 at 14:57
  • 1
    Saved the day, yet another thank you. Curiously odd link is it not, yet works: http://go.microsoft.com/fwlink/?LinkId=691126&fixForIE=.exe. – gseattle May 08 '19 at 01:44
  • use pycryptodome instead it has a wheel with all the vc++ libraries compiled, so you do not need it. for me it is a big issue not having to install vc++ on all windows clients. – MortenB Oct 15 '19 at 10:01
  • try to do this on a computer you aren't the administrator on. – Michael Tamillow Nov 12 '20 at 20:23
  • 6
    [Download Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) --> Run exe --> Check C++ build tools --> check MSVC v142 and Windows 10 SDK --> wait for installation to finish – xinthose Jan 15 '21 at 22:02
  • 2
    @xinthose I appreciate letting us know exactly which packages to download/install, instead of the entire thing – wrapperapps Aug 24 '22 at 17:17
  • Required packages size is about `5GB`. I had no memory to download and install packages with `python3.11.0`, so i just switched back to `python3.10.6` and everything worked fine without downloading visual studio c++ build tools – 555Russich Dec 09 '22 at 13:35
98

If you already have Visual Studio Build Tools installed but you're still getting that error, then you may need to "Modify" your installation to include the Visual C++ build tools.

To do that:

  1. Open up the Visual Studio Installer (you can search for it in the Start Menu if needed).

  2. Find Visual Studio Build Tools and click "Modify":

enter image description here

  1. Add a checkmark to Visual C++ build tools and then click "Modify" in the bottom right to install them:

enter image description here

After the C++ tools finish installing, run the pip command again and it should work.

Pikamander2
  • 7,332
  • 3
  • 48
  • 69
  • 64
    With VS 2019, this option is found in the "Individual Components" tab of VS installer, under the name of "MSVC v140 - VS2015 C++ Build Tools (v14.00)" and needs to download 800 MB. – mins Nov 27 '20 at 18:54
  • 5
    How to do this via regular windows cmd? – shs_sf Jan 03 '21 at 22:22
  • 3
    Anyone know what to do when you have installed all the C++ options on the build tools installer and rebooted and upgraded setuptools but still get the same error message? – jon_two Jun 10 '21 at 07:10
  • 7
    @mins is it required to download `windows universal crt sdk` with it? Totally, it is requiring me 3.64GB of space!!! – Sourav Kannantha B Nov 01 '21 at 11:30
  • 4
    @shs_sf If you like using chocolatey (as I do) then you can install these packages: `cinst visualstudio2019buildtools` `cinst visualstudio2019-workload-vctools` – barbalion Nov 16 '21 at 20:24
  • @barbalion was losing my mind trying to install `pyworld`, thank you for this comment. honestly you should make this an answer since it's much better alternative to using the official installer – éclairevoyant Jun 01 '22 at 00:09
  • 7
    For 2022: you pick the "C++ build tools" it is not the same icon than this screenshot. And you accept the 7GB install :( – Laurent Pinson Jul 01 '22 at 14:17
  • 3
    In order to run a 20 line python script I am told to install a python package which 3.75GB of VS build tools. – Salman A Oct 10 '22 at 19:53
17

I landed on this question after searching for "Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools". I got this error in Azure DevOps when trying to run pip install to build my own Python package from a source distribution that had C++ extensions. In the end all I had to do was upgrade setuptools before calling pip install:

pip install --upgrade setuptools

So the advice here about updating setuptools when installing from source archives is right after all:). That advice is given here too.

snark
  • 2,462
  • 3
  • 32
  • 63
15

I got this error when I tried to install pymssql even though Visual C++ 2015 (14.0) is installed in my system.

I resolved this error by downloading the .whl file of pymssql from here.

Once downloaded, it can be installed by the following command :

pip install python_package.whl

Hope this helps

ashraful16
  • 2,742
  • 3
  • 11
  • 32
JKC
  • 2,498
  • 6
  • 30
  • 56
9

As an alternative to installing Visual C++, there is a way by installing an additional package in Conda (this option doesn't require admin rights). This worked for me:

conda install libpython m2w64-toolchain -c msys2
Guido
  • 6,182
  • 1
  • 29
  • 50
  • 2
    Thanks. Given others have mentioned cryptography support, an explanation would be helpful, just to know what is installed and why this is an acceptable alternative. Blindly/randomly adding libraries to a computer isn't generally a good option. Perhaps also linking to the original source, as I imagine you didn't invent the solution. – mins Nov 27 '20 at 18:29
  • 2
    Love you man. I can never get this problem to fix itself on Windows. Tried downloading every C++ compiler thing Microsoft have with no help. Tried editing some environment variables to point to the Common7/Tools path and it didn't work. But this worked. – Corey Levinson Oct 02 '21 at 05:45
8

I faced the same problem. Found the fix here.

Basically just install this.

shasum output:

3e0de8af516c15547602977db939d8c2e44fcc0b  visualcppbuildtools_full.exe

md5sum output:

MD5 (visualcppbuildtools_full.exe) = 8d4afd3b226babecaa4effb10d69eb2e

Run your pip installation command again. If everything works fine, its good. Or you might face the following error like me:

Finished generating code
    LINK : fatal error LNK1158: cannot run 'rc.exe'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158

Found the fix for the above problem here: Visual Studio can't build due to rc.exe

That basically says

Add this to your PATH environment variables:

C:\Program Files (x86)\Windows Kits\8.1\bin\x86

Copy these files:

rc.exe
rcdll.dll

From

C:\Program Files (x86)\Windows Kits\8.1\bin\x86

To

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin

It works like a charm

ashraful16
  • 2,742
  • 3
  • 11
  • 32
  • Thanks, the above finally fixed it for me. One difference though, my folder is called C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin – Mathias Thorsen Dec 10 '20 at 08:52
  • @MathiasThorsen the folder name is based on your Visual Studio version, they vary from version to version. – Ratul Hasan Aug 14 '21 at 08:24
7

Updated link here for download Microsoft Visual C++ 14.0

It works for me without a Visual Studio downloader

GooDeeJAY
  • 1,681
  • 2
  • 20
  • 27
iampritamraj
  • 196
  • 2
  • 6
5

Pycrypto has vulnerabilities assigned the CVE-2013-7459 number, and the repo hasn't accept PRs since June 23, 2014.

Pycryptodome is a drop-in replacement for the PyCrypto library, which exposes almost the same API as the old PyCrypto, see Compatibility with PyCrypto.

If you haven't install pycrypto yet, you can use pip install pycryptodome to install pycryptodome in which you won't get Microsoft Visual C++ 14.0 issue.

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
1

On Windows, I strongly recommand installing the latest version of Visual Studio Community. It's free, you will maybe miss some build tools if you only install vc_redist, so you can easily install package by pip instead of wheel, it save lot of time.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Alen Lee
  • 2,479
  • 2
  • 21
  • 30
  • 2
    As of 2020 having VS Community installed doesn't prevent to see this error. But perhaps you need to have the C++ "workload" installed, which I don't have. – mins Nov 27 '20 at 17:52
1

None of the solutions proposed by other people here worked for me.

So in my case I had to uinstall ALL older versions of Microsoft Visual C++ Redistributable from my computer:

enter image description here

Only the newest one (in my case 2015-2022) should be left!

After uinstalling I ran this command:

pip install <your_lib_name>

and everything worked great after that.

westman379
  • 493
  • 1
  • 8
  • 25
0

Killer solution: install nodejs and tick the option of install chocolatey and other necessary tools... and it will install the tools required to setup a development environment.

Ahmed I. Elsayed
  • 2,013
  • 2
  • 17
  • 30
  • 2
    Installing nodejs is rarely the solution, especially when the problem is to do with MS Build Tools for Python. – jon_two Aug 23 '22 at 10:07
0

Three steps I follow for this error:

  1. C++ Build tools are installed
  2. pip install --upgrade setuptools
  3. try using conda to install, conda may have the compiled version which won't need the build tools
0

I'm going to add another answer here since I was caught on this for hours and finally figured out what the cause was and it was painfully unintuitive.

I kept getting the "Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools" when trying to install a python depedndency. No matter how many times I re-installed it, the error persisted.

After hours of debugging, the issue ended up being that it was not getting added to my PATH. Apparently with everything I had on my path, adding it would put it at 2050 characters, and Windows limits it at 2048. My guess is the installer is just silently failing on this, hence no indication.

Find the path of the build tools, (mine was C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86 ), and append it to your path.

If you have the same issue as I did, you'll need to shorten the path by removing other elements here. I had a few old Python version I was able to remove in order to go under the character limit.

  • "My guess is the installer is just silently failing on this, hence no indication." The resulting PATH is a valid value for the environment variable; it just has a nonexistent directory at the end (it's not the responsibility of any tool in particular to check for this) and therefore the compiler isn't found. The install process is as noisy as ever about the fact that a compiler wasn't found; I don't know what you would consider "not silent". – Karl Knechtel Aug 25 '23 at 18:47
  • I would consider not silent being an actual error thrown on install that a path wasn't added. The compiler WAS installed, it just wasn't being added to the path. Programs trying to consume it throw a misleading error saying it's not installed. – Matthew Stanley Aug 26 '23 at 19:24
  • But as far as I'm aware, a path *was* added (it was just truncated), and that path addition happened in a context that the installer didn't have any way to know about. – Karl Knechtel Aug 26 '23 at 20:42
  • There was no evidence of a partial path existing. In any scenario, I don't get the point of being pedantic on this. No matter how you split hairs, it didn't work. – Matthew Stanley Aug 28 '23 at 22:23
-1

Try doing this:

py -m pip install pipwin
py -m pipwin install PyAudio
Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
praveen d
  • 65
  • 1
  • 2
  • what are this packages? – ediordna Nov 16 '21 at 16:49
  • 1
    @ediordna it appears to be some kind of wrapper that searches for pre-built binaries for Windows rather than letting Pip attempt to compile them locally. It also appears to be no longer maintained. – Karl Knechtel Aug 25 '23 at 18:45