ImportError: cannot import name Random

Jmnote bot (토론 | 기여)님의 2020년 12월 27일 (일) 13:30 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
ImportError: cannot import name Random

1 문제상황[ | ]

[root@zetawiki ~]# 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@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.0.1
→ 버전이 낮음. Crypto.Random은 2.1.0alpha1 에서 추가됨

3 pycrypto 업그레이드[ | ]

4 확인[ | ]

[root@zetawiki ~]# pip list | grep pycrypto
pycrypto (2.6.1)
[root@zetawiki ~]# 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@zetawiki ~]# 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@zetawiki ~]# 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@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.6.1

7 같이 보기[ | ]

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