ImportError: no module named Crypto.Cipher

When I try to run app.py (Python 3.3, PyCrypto 2.6), my virtualenv keeps returning the above error. The import operation is just from Crypto.Cipher import AES . I was looking for duplicates, and you could say that there are some, but I tried the solutions (although most of them are not even solutions), and nothing worked.

You can see which files for PyCrypto are below:

+108
python pip easy-install virtualenv pycrypto
Oct 27 '13 at
source share
21 answers

I had the same issue (albeit on Linux). The solution was pretty simple - add:

 libraries: - name: pycrypto version: "2.6" 

to my app.yaml file. Since this worked correctly in the past, I assume this is a new requirement.

+56
Nov 16 '13 at 3:28
source share

I had the same problem on my Mac when installing with pip . Then I uninstalled pycrypto and installed it again with easy_install , for example:

 pip uninstall pycrypto easy_install pycrypto 

also, as Luke said: If you have problems running these commands, be sure to run them as admin (sudo)

Hope this helps!

+180
Jan 07 '14 at 9:48
source share

I came across this on a Mac, and it seems that this is due to the fact that, unfortunately, the so-called “crypto” module (not sure what it is for) is installed next to picripto via pip.

The fix is ​​similar to removing crypto and picrypto using pip:

 sudo pip uninstall crypto sudo pip uninstall pycrypto 

and reinstall pycrypto:

 sudo pip install pycrypto 

Now it works as expected when I do something like:

 from Crypto.Cipher import AES 
+92
Aug 19 '16 at 10:54 on
source share

On a poppy ... if you come across this .. try to see if you can import crypto instead?

If so .. the package name is a C vs C problem. To get around this, simply add these lines at the beginning of your script.

 import crypto import sys sys.modules['Crypto'] = crypto 

You know that you can import paramiko successfully.

+30
Jan 14 '14 at 14:32
source share

enter the command:

 sudo pip install pycrypto 
+18
Dec 9 '13 at 9:02
source share

I have found a solution. The problem is probably in the case of sensitivity (on Windows).

Just change the folder name:

  • C:\Python27\Lib\site-packages\crypto
  • to: C:\Python27\Lib\site-packages\crypto

This is what the folder was named after installing pycrypto: enter image description here

I changed it to: enter image description here

And now the following code is working fine: enter image description here

+16
Jul 30 '16 at 22:39
source share

Removing crypto and pycrypto works for me. Then install only pycrypto :

 pip uninstall crypto pip uninstall pycrypto pip install pycrypto 
+16
Sep 28 '17 at 8:22
source share

if you use redhat, fedora, centos:

sudo yum install pycrypto

for my case I can not install it with pip

+8
Feb 28 '14 at 15:15
source share

I had the same problem 'ImportError: No module named Crypto.Cipher' , since using GoogleAppEngineLauncher (version> 1.8.X) with GAE Boilerplate on OSX 10.8.5 (Mountain Lion). In the Google App Engine SDK with python 2.7 runtime, it is recommended to use pyCrypto 2.6. The solution that worked for me was ...

1) Download the pycrypto2.6 source code somewhere ( ~/Downloads/pycrypto26 )

e.g. git clone https://github.com/dlitz/pycrypto.git

2) cd ( cd ~/Downloads/pycrypto26 ), then

3) Run the following terminal command inside the previous folder to manually install pyCrypto 2.6 in the GAE folder.

 sudo python setup.py install --install-lib /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine 
+8
Sep 20 '14 at 13:17
source share

Try with pip3 :

 sudo pip3 install pycrypto 
+3
Jul 01 '17 at 14:06
source share

It could be a problem loading python modules installed via pip. See This Answer. It is not possible to download the Python modules installed via pip from the site-packages directory and try something like

 python -m pip install pycrypto 
+2
Sep 28 '17 at 16:48
source share

For CentOS 7.4, I installed pip first and then pycrypto using pip:

 > sudo yum -y install python-pip > sudo python -m pip install pycrypto 
+2
Dec 11 '17 at 11:57
source share

Worked for me (Ubuntu 17.10)

Removing venv and creating it again with python v3.6

 pip3 install PyJWT sudo apt-get install build-essential libgmp3-dev python3-dev pip3 install cryptography pip3 install pycryptodome pip3 install pycryptodomex 

Pycrypto is deprecated, had problems with it, used Pycryptodome

+2
Mar 07 '18 at 12:33
source share

For Windows 7:

I went through this error "Crypo.Cipher import AES module error"

To install Pycrypto on Windows,

Try this on the command line,

Set path = C: \ Python27 \ Scripts (path where easy_install is located)

Then do the following:

easy_install pycrypto

For Ubuntu:

Try it,

Download Pycrypto from " https://pypi.python.org/pypi/pycrypto "

Then change your current path to the loaded path using your terminal:

For example: root @ xyz-virtual-machine: ~ / pycrypto-2.6.1 #

Then perform the following operations using the terminal:

install python setup.py

It worked for me. Hope works for everyone.

+1
Apr 12 '15 at 9:31 on
source share

I solve this problem by changing the case of the first letter to upper case. Make sure that `` from Crypto.Cipher imports AES '' not `` from crypto.Cipher import AES ''.

+1
Jun 11. '15 at 6:18
source share

This problem can be fixed by installing the C ++ compiler (python27 or python26). Download it from Microsoft https://www.microsoft.com/en-us/download/details.aspx?id=44266 and run the command: pip install pycrypto to start gui web access when you kill the easy_install.exe process.

+1
May 31 '17 at 20:06
source share

Today I have from Crypto.Cipher import AES same problem when importing from Crypto.Cipher import AES even if I installed / reinstalled pycrypto several times. Complete this because pip is python3 by default.

~ pip --version pip 18.0 from/usr/local/lib/python3.7/site-packages/pip (python 3.7)

installing pycrypo with pip2 should solve this problem.

+1
Aug 16
source share

Maybe you should do this: pycryptodome == 3.6.1 add it to requirements.txt and set that should fix the error report. it works for me!

+1
Dec 03 '18 at 8:25
source share

If you are macos, rename the lib/python3.7/site-packages/crypto folder to lib/python3.7/site-packages/Crypto

+1
May 10 '19 at 2:35
source share

ATTENTION: do not use pycrypto anymore!

As you can read on this page , using pycrypto no longer safe:

Pycrypto is vulnerable to buffer overflows on the heap in the ALGnew function in block_templace.c. This allows remote attackers to execute arbitrary code in a python application. He was assigned the number CVE-2013-7459 .

Pycrypto did not release a single patch of this vulnerability, and since June 20, 2014, no obligations have been made to the project.

SOLUTION: use Python3 and pycryptodome !

TL; DR: pip3 install pycryptodome

Setting up a new virtual environment

To install the virtual environment and configure everything, use the following commands:

 # install python3 and pip3 sudo apt update sudo apt upgrade sudo apt install python3 sudo apt install python3-pip # install and create a virtual environment # cd to or mkdir the folder where you want your venv pip3 install virtualenv python3 -m virtualenv . # now activate your venv and install pycryptodome source bin/activate pip3 install pycryptodome # check if everything worked: # start the interactive python console and import the Crypto module # when there is no import error then it worked python >>> from Crypto.Cipher import AES >>> exit() # don't forget to deactivate your venv again deactivate 

See pycryptodome.org for more information .

+1
Sep 24 '19 at 9:38
source share

I'm from 3.7. The problem remains after I try to install crypto. And Pycrypto just fails in my case. As a result, my build went through the package below: pip install pycryptodome

0
Aug 27 '19 at 6:21
source share



All Articles