ImportError: cannot import name Random

Jmnote (토론 | 기여)님의 2014년 9월 4일 (목) 02:56 판 (→‎확인)
ImportError: cannot import name Random

1 문제상황

[root@jmnote ~]# python test.py
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from Crypto import Random
ImportError: cannot import name Random

2 Crypto 모듈 버전 확인

[root@jmnote ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.0.1
→ 버전이 낮음. Crypto.Random은 2.1.0alpha1 에서 추가됨

3 pycrypto 업그레이드

4 확인

[root@jmnote ~]# pip list | grep pycrypto
pycrypto (2.6.1)
[root@jmnote ~]# python -c 'import Crypto; print( Crypto.__version__ );'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named Crypto
→ ??? 업그레이드가 되었는데도 안된다..

5 pycrypto 재설치

[root@jmnote ~]# pip uninstall pycrypto
Uninstalling pycrypto:
  /usr/lib64/python2.6/site-packages/Crypto/Cipher/AES.py
  /usr/lib64/python2.6/site-packages/Crypto/Cipher/AES.pyc
... (생략)
  /usr/lib64/python2.6/site-packages/Crypto/pct_warnings.pyc
  /usr/lib64/python2.6/site-packages/pycrypto-2.6.1-py2.6.egg-info
Proceed (y/n)? y
  Successfully uninstalled pycrypto
[root@jmnote ~]# pip install pycrypto
Downloading/unpacking pycrypto
  Running setup.py egg_info for package pycrypto
Installing collected packages: pycrypto
  Running setup.py install for pycrypto
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
Successfully installed pycrypto
Cleaning up...

6 확인 2

[root@jmnote ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.6.1

7 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}