"ImportError: cannot import name Random"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
2번째 줄: 2번째 줄:


==문제상황==
==문제상황==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python test.py
[root@zetawiki ~]# python test.py
Traceback (most recent call last):
Traceback (most recent call last):
8번째 줄: 8번째 줄:
     from Crypto import Random
     from Crypto import Random
ImportError: cannot import name Random
ImportError: cannot import name Random
</source>
</syntaxhighlight>


==Crypto 모듈 버전 확인==
==Crypto 모듈 버전 확인==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.0.1
2.0.1
</source>
</syntaxhighlight>
:→ 버전이 낮음. Crypto.Random은  2.1.0alpha1 에서 추가됨
:→ 버전이 낮음. Crypto.Random은  2.1.0alpha1 에서 추가됨


21번째 줄: 21번째 줄:


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


==pycrypto 재설치==
==pycrypto 재설치==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# pip uninstall pycrypto
[root@zetawiki ~]# pip uninstall pycrypto
Uninstalling pycrypto:
Uninstalling pycrypto:
44번째 줄: 44번째 줄:
Proceed (y/n)? y
Proceed (y/n)? y
   Successfully uninstalled pycrypto
   Successfully uninstalled pycrypto
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# pip install pycrypto
[root@zetawiki ~]# pip install pycrypto
Downloading/unpacking pycrypto
Downloading/unpacking pycrypto
54번째 줄: 54번째 줄:
Successfully installed pycrypto
Successfully installed pycrypto
Cleaning up...
Cleaning up...
</source>
</syntaxhighlight>


==확인 2==
==확인 2==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.6.1
2.6.1
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 12월 27일 (일) 13:30 기준 최신판

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 }}