ImportError: No module named Crypto.Cipher

前端 未结 25 1198
后悔当初
后悔当初 2020-11-28 04:08

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

相关标签:
25条回答
  • 2020-11-28 04:51

    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!

    0 讨论(0)
  • 2020-11-28 04:52

    I had the same problem on my Mac when installing with pip. I then removed pycrypto and installed it again with easy_install, like this:

    pip uninstall pycrypto
    easy_install pycrypto
    

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

    Hope this helps!

    EDIT: As winklerr correctly notes above, pycrypto is no longer safe. Use pycryptodome instead, it is a drop-in replacement

    0 讨论(0)
  • 2020-11-28 04:53

    It could be a problem of loading python modules installed via pip. Refer to this answer Can't load Python modules installed via pip from site-packages directory and try something like

    python -m pip install pycrypto
    
    0 讨论(0)
  • 2020-11-28 04:53

    This worked for me

    pip install pycryptodome==3.4.3
    
    0 讨论(0)
  • 2020-11-28 04:54

    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
    
    0 讨论(0)
  • 2020-11-28 04:55

    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

    0 讨论(0)
提交回复
热议问题