Programming

ImportError : Crypto.Cipher라는 모듈이 없습니다.

procodes 2020. 8. 4. 20:12
반응형

ImportError : Crypto.Cipher라는 모듈이 없습니다.


app.py (Python 3.3, PyCrypto 2.6)를 실행하려고하면 virtualenv가 위에 나열된 오류를 계속 반환합니다. 내 수입 명세서는 단지 from Crypto.Cipher import AES입니다. 나는 중복을 찾았고 일부가 있다고 말할 수도 있지만 해결책을 시도했지만 (대부분 해결책조차는 아니지만) 아무런 효과가 없었습니다.

아래에서 PyCrypto의 파일이 무엇인지 확인할 수 있습니다.


나는 같은 문제가 있었다 (리눅스에서는). 해결책은 매우 간단했습니다.

libraries:
- name: pycrypto
  version: "2.6"

app.yaml파일에. 이것은 과거에 올바르게 작동했기 때문에 이것이 새로운 요구 사항이라고 가정합니다.


로 설치할 때 Mac에서도 동일한 문제가 발생했습니다 pip. 그런 다음 다음 pycrypto같이 제거 하고 다시 설치했습니다 easy_install.

pip uninstall pycrypto
easy_install pycrypto

또한 Luke가 언급 한대로 :이 명령을 실행하는 데 문제가 있으면 관리자 (sudo)로 실행하십시오.

도움이 되었기를 바랍니다!


Mac 에서도이 문제가 발생했지만 불행히도 비슷한 이름의 "crypto"모듈 (무엇인지 확실하지 않음)을 pip를 통해 pycrypto와 함께 설치하는 것과 관련이있는 것 같습니다.

수정 프로그램은 pip로 crypto와 pycrypto를 모두 제거하는 것으로 보입니다.

sudo pip uninstall crypto
sudo pip uninstall pycrypto

pycrypto를 다시 설치하십시오.

sudo pip install pycrypto

이제 다음과 같은 작업을 수행하면 예상대로 작동합니다.

from Crypto.Cipher import AES

Mac에서 ...이 문제가 발생하면 암호를 가져올 수 있는지 확인하십시오.

그렇다면 .. 패키지 이름은 문제 Cc입니다. 이 문제를 해결하려면이 줄을 스크립트 상단에 추가하십시오.

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

paramiko를 성공적으로 가져올 수 있어야합니다.


유형 명령 :

sudo pip install pycrypto

해결책을 찾았습니다. 대소 문자 구분이 문제 일 수 있습니다 (Windows).

폴더 이름을 변경하십시오.

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

다음은 pycrypto 설치 후 폴더 이름이 지정된 방식입니다. 여기에 이미지 설명을 입력하십시오

나는 그것을 다음과 같이 바꿨다. 여기에 이미지 설명을 입력하십시오

이제 다음 코드가 정상적으로 작동합니다. 여기에 이미지 설명을 입력하십시오


제거 crypto하고 pycrypto작동합니다. 그런 다음 만 설치하십시오 pycrypto.

pip uninstall crypto 
pip uninstall pycrypto 
pip install pycrypto

redhat, fedora, centos를 사용하는 경우 :

sudo yum install pycrypto

내 경우에는 pip를 사용하여 설치할 수 없습니다


'ImportError: No module named Crypto.Cipher'OSX 10.8.5 (Mountain Lion)에서 GAE Boilerplate과 함께 GoogleAppEngineLauncher (버전> 1.8.X)를 사용했기 때문에 동일한 문제가 발생했습니다 . python 2.7 런타임이 포함 된 Google App Engine SDK에서 pyCrypto 2.6이 권장 버전입니다. 나를 위해 일한 해결책은 ...

1) pycrypto2.6 소스 추출을 어딘가에 다운로드하십시오 ( ~/Downloads/pycrypto26)

예 : git clone https://github.com/dlitz/pycrypto.git

2) cd( cd ~/Downloads/pycrypto26) 그런 다음

3) GAE 폴더에 pyCrypto 2.6을 수동으로 설치하려면 이전 폴더 내에서 다음 터미널 명령을 실행하십시오.

sudo python setup.py install --install-lib /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine

Try with pip3:

sudo pip3 install pycrypto

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

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

> sudo yum -y install python-pip 
> sudo python -m pip install pycrypto

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


For Windows 7:

I got through this error "Module error Crypo.Cipher import AES"

To install Pycrypto in Windows,

Try this in Command Prompt,

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

Then execute the following,

easy_install pycrypto

For Ubuntu:

Try this,

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

Then change your current path to downloaded path using your terminal:

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

Then execute the following using the terminal:

python setup.py install

It's worked for me. Hope works for all..


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''.


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 re-run the command : pip install pycrypto to run the gui web access when you kill the process of easy_install.exe.


To date, I'm having same issue when importing from Crypto.Cipher import AES even i've installed/reinstalled pycrypto 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 pycrypo with pip2 should solve this issue.


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!


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


WARNING: Don't use pycrypto anymore!

As you can read on this page, the usage of pycrypto is not safe anymore:

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

Pycrypto didn’t release any fix to that vulnerability and no commit was made to the project since Jun 20, 2014.

SOLUTION: Use Python3 and pycryptodome!

TL;DR: pip3 install pycryptodome

Setting up a new virtual environment

To install a virtual environment and setup 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

For more information, see pycryptodome.org


I'm with 3.7. The issue remains after I try to install crypto. And pycrypto just fails in my case. So in the end my build passed via package below: pip install pycryptodome

참고 URL : https://stackoverflow.com/questions/19623267/importerror-no-module-named-crypto-cipher

반응형