ImportError: No module named Crypto.Cipher

前端 未结 25 1196
后悔当初
后悔当初 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:43

    On the mac... if you run into this.. try to see if you can import crypto instead?

    If so.. the package name is the issue C vs c. To get around this.. just add these lines to the top of your script.

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

    You know should be able to import paramiko successfully.

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

    I found the solution. Issue is probably in case sensitivity (on Windows).

    Just change the name of the folder:

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

    This is how folder was named after installation of pycrypto:

    I've changed it to:

    And now the following code works fine:

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

    type command:

    sudo pip install pycrypto
    
    0 讨论(0)
  • 2020-11-28 04:43

    I solve this problem by change the first letter case to upper. Make sure ''from Crypto.Cipher import AES'' not ''from crypto.Cipher import AES''.

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

    To date, I'm having same issue when importing from Crypto.Cipher import AES even when I've installed/reinstalled pycrypto a few times. End up it's because pip defaulted to python3.

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

    installing pycrypto with pip2 should solve this issue.

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

    Well this might appear weird but after installing pycrypto or pycryptodome , we need to update the directory name crypto to Crypto in lib/site-packages

    Reference

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