16

I am trying to install PyCrypto 2.6 Library on my computer. But I keep getting the following error

D:\Software\Python\package\pycrypto-2.6>python setup.py build
running build
running build_py
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

building 'Crypto.Random.OSRNG.winrandom' extension
error: Unable to find vcvarsall.bat

My System has Windows 8 Pro 64-bit, Visual Studio Enterprise 2012 and Python 3.3

To fix the error I tried to set the Environment Variable VS90COMNTOOLS=%VS110COMNTOOLS% as advised by fmuecke in the post error: Unable to find vcvarsall.bat but it didn't work for me.

Can any one please advise me how to fix this error.

FYI, I don't to install VC2008 etc..

Community
  • 1
  • 1
Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59

8 Answers8

13

I managed to install PyCrypto 2.6 by using the prebuilt binary for Python3.3 from The Voidspace Python Modules.

It doesn't actually fix the error: Unable to find vcvarsall.bat for other package which don't have a prebuilt binaries available.

However it eliminates the need to build PyCrypto package, allowing me to install PyCrypto on my system without getting the error.

Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59
  • 2
    I did this, using `easy_install pycrypto-2.6.win32-py3.3.exe` but when I try to `from Crypto.PublicKey import RSA` I get: `from . import winrandom ImportError: DLL load failed: The specified module could not be found.` – deed02392 Mar 28 '14 at 10:21
5

I've just used

https://www.microsoft.com/en-gb/download/details.aspx?id=44266

with setuptools > 6.0 and run

'pip install pycrypto'

and it worked

  • 1
    Link-only answers are not particularly helpful if the link goes dead - if you assume the link is dead, what can I still get from your answer? All I know is that I need to download something first before the rest of your instructions. – stwalkerster Oct 26 '15 at 16:23
  • As a note, the download is for "Microsoft Visual C++ Compiler for Python 2.7", and this solved the issue for me. (Visual Studio 2015 Community Edition did not) – user Jul 06 '16 at 12:55
  • totally worked, i must say that i had python 3.3 installed previously, i had to remove everything. and start installing python 2.7 from scratch. after this was installed, everything just worked. thanks! – Ivan Perez Sep 25 '18 at 03:45
  • How do you do the "setuptools > 6.0" part? – m0a Feb 27 '20 at 11:34
4

I know this is an old question, but I also need today much time to get paramiko wokring. I want to use Python 3.4 and on voidspace, there are no prebuild binaries for 3.4.

Finally, I got a wokring pycrypto by installing "Microsoft Studio Express 2010 C++" and run from the pycrypto 2.7 folder:

python setup.py build --compiler msvc
python setup.py install
python setup.py bdist_wininst

All the "tricks" with enviroment variables doesn't work for me.

If it helps somebody, all the thanks goes to: http://flintux.wordpress.com/2014/04/30/pycrypto-for-python-3-4-on-windows-7-64bit/

3

For Python 3.5 you can do this:

Install a PyCrypto binary from this site : https://github.com/sfbahr/PyCrypto-Wheels

The best way to do it, is:

64bits Python

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto

32bits Python

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win32.whl pycrypto

Of course replace c:\Python35\Scripts\pip.exe by your python pip path

To know your python version, run python and look at the architecture displayed between brackets:

C:\Users\utilisateur>python Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Hope this can help.

2

You may install mingw64 and then run from the PyCrypto unzipped files directory:

python setup.py build --compiler=mingw32

GiorgioG
  • 116
  • 6
2

Updated answer for 2021 (many other answers are outdated)

Python 2.7 is EOL (end-of-life), and Microsoft has removed the download link for the Visual C++ 8.0 compiler, which was needed for compiling native Python 2.7 modules (and which they later called something like "C++ compiler for Python 2.7", VCForPython27.msi). Therefore pip install pycrypto no longer works.

To see for yourserlf, check out this answer with a now defunct download link. Don't search for VCForPython27 on GitHub - you will find projects, but they are not official Microsoft projects, so you may want to stay away from those.

If you find yourself in this situation, then seriously, it's high time to migrate to Python 3. Don't download old builds of PyCrypto or Visual C++ 8.0 from random websites or from web archive links, especially not since this is a library for cryptography that should be kept up to date.

Florian Winter
  • 4,750
  • 1
  • 44
  • 69
0

I am using Windows 10 - All I needed to do was update my system with Visual C++ Build Tools 2015 which I found on this page: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/

About mid-page, you will see some download options - choose your python version and download the correct package

I then re-imported the program I was trying to install and NO more error! Woohoo!

Reed Miller
  • 161
  • 1
  • 3
0

if you are VS 2010

SET VS90COMNTOOLS=%VS100COMNTOOLS%

VS 2012

SET VS90COMNTOOLS=%VS110COMNTOOLS%

VS 2013

SET VS90COMNTOOLS=%VS120COMNTOOLS%

and then python setup.py install

hhhhhh
  • 1