89

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
  • 19,150
  • 23
  • 79
  • 104
Studentu
  • 1,085
  • 1
  • 8
  • 11
  • 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

13 Answers13

107

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.

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.

David Cullen
  • 13,143
  • 4
  • 35
  • 60
  • 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. – David Cullen 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. – David Cullen 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. – David Cullen Jul 16 '17 at 00:56
  • 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
  • 3
    [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
  • 1
    @xinthose save my day! – totesz09 Jan 26 '22 at 11:03
69

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
  • 5,875
  • 3
  • 42
  • 57
  • 37
    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
  • 4
    How to do this via regular windows cmd? – shs_sf Jan 03 '21 at 22:22
  • 2
    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
  • 4
    @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
  • 3
    @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
15

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,092
  • 29
  • 58
14

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,498
  • 2
  • 7
  • 27
JKC
  • 2,348
  • 4
  • 28
  • 53
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,498
  • 2
  • 7
  • 27
  • 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
8

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
  • 5,244
  • 1
  • 25
  • 46
  • 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
4

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
  • 16,448
  • 3
  • 17
  • 42
4

Updated link here for download Microsoft Visual C++ 14.0

It works for me without a Visual Studio downloader

GooDeeJAY
  • 1,527
  • 1
  • 17
  • 25
iampritamraj
  • 148
  • 1
  • 6
1

On Windows, I strongly recommand installing latest Visual Stuido 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

Alen Lee
  • 2,389
  • 2
  • 20
  • 29
  • 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
0

Try doing this:

py -m pip install pipwin
py -m pipwin install PyAudio
Daemon Painter
  • 2,785
  • 2
  • 24
  • 38
praveen d
  • 67
  • 1
  • 2
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
  • 1,941
  • 2
  • 12
  • 30
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

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
  • 439
  • 1
  • 5
  • 20