ImportError: No module named Crypto.Cipher

2019-01-30 12:45发布

When I try to run app.py (Python 3.3, PyCrypto 2.6) my virtualenv keeps returning the error listed above. My import statement is just from Crypto.Cipher import AES. I looked for duplicates and you might say that there are some, but I tried the solutions (although most are not even solutions) and nothing worked.

You can see what the files are like for PyCrypto below:

18条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-30 13:35

Maybe you should this: pycryptodome==3.6.1 add it to requirements.txt and install, which should eliminate the error report. it works for me!

查看更多
放荡不羁爱自由
3楼-- · 2019-01-30 13:37

I've 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 Google App Engine SDK with python 2.7 runtime, pyCrypto 2.6 is the suggested version. The solution that worked for me was...

1) Download pycrypto2.6 source extract it somewhere(~/Downloads/pycrypto26)

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

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

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

sudo python setup.py install --install-lib /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine
查看更多
家丑人穷心不美
4楼-- · 2019-01-30 13:38

I ran into this on Mac as well, and it seems to be related to having an unfortunately similarly named "crypto" module (not sure what that is for) installed alongside of pycrypto via pip.

The fix seems to be removing both crypto and pycrypto with pip:

sudo pip uninstall crypto
sudo pip uninstall pycrypto

and reinstalling pycrypto:

sudo pip install pycrypto

Now it works as expected when I do something like:

from Crypto.Cipher import AES
查看更多
The star\"
5楼-- · 2019-01-30 13:41

if you are using redhat,fedora, centos :

sudo yum install pycrypto

for my case I coouldnot install it using pip

查看更多
等我变得足够好
6楼-- · 2019-01-30 13:41

Try with pip3:

sudo pip3 install pycrypto
查看更多
闹够了就滚
7楼-- · 2019-01-30 13:44

type command:

sudo pip install pycrypto
查看更多
登录 后发表回答