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

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 2명의 중간 판 14개는 보이지 않습니다)
2번째 줄: 2번째 줄:


==문제상황==
==문제상황==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# python test.py
[root@zetawiki ~]# python test.py
Traceback (most recent call last):
Traceback (most recent call last):
   File "test.py", line 2, in <module>
   File "test.py", line 2, in <module>
     from Crypto import Random
     from Crypto import Random
ImportError: cannot import name Random
ImportError: cannot import name Random
</source>
</syntaxhighlight>


==Crypto 모듈 버전 확인==
==Crypto 모듈 버전 확인==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# 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 에서 추가됨


==python-pip 설치==
==pycrypto 업그레이드==
{{참고|리눅스 python-pip 설치}}
{{참고|pycrypto 업그레이드}}


==Crypto 설치==
==확인==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@koreanpol ~]# pip install Crypto
[root@zetawiki ~]# pip list | grep pycrypto
Downloading/unpacking Crypto
pycrypto (2.6.1)
  Downloading crypto-1.1.0.tar.gz
</syntaxhighlight>
  Running setup.py egg_info for package Crypto
<syntaxhighlight lang='console'>
Downloading/unpacking rsa (from Crypto)
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
  Downloading rsa-3.1.4.tar.gz
Traceback (most recent call last):
  Running setup.py egg_info for package rsa
   File "<string>", line 1, in <module>
    warning: no files found matching 'README'
ImportError: No module named Crypto
Downloading/unpacking pyasn1>=0.1.3 (from rsa->Crypto)
</syntaxhighlight>
  Downloading pyasn1-0.1.7.tar.gz (68kB): 68kB downloaded
:→ ??? 업그레이드가 되었는데도 안된다..
   Running setup.py egg_info for package pyasn1
 
Installing collected packages: Crypto, rsa, pyasn1
==pycrypto 재설치==
  Running setup.py install for Crypto
<syntaxhighlight lang='console'>
  Running setup.py install for rsa
[root@zetawiki ~]# pip uninstall pycrypto
    warning: no files found matching 'README'
Uninstalling pycrypto:
    Installing pyrsa-encrypt-bigfile script to /usr/bin
  /usr/lib64/python2.6/site-packages/Crypto/Cipher/AES.py
    Installing pyrsa-encrypt script to /usr/bin
  /usr/lib64/python2.6/site-packages/Crypto/Cipher/AES.pyc
    Installing pyrsa-verify script to /usr/bin
... (생략)
    Installing pyrsa-sign script to /usr/bin
  /usr/lib64/python2.6/site-packages/Crypto/pct_warnings.pyc
    Installing pyrsa-priv2pub script to /usr/bin
  /usr/lib64/python2.6/site-packages/pycrypto-2.6.1-py2.6.egg-info
    Installing pyrsa-decrypt script to /usr/bin
Proceed (y/n)? y
    Installing pyrsa-keygen script to /usr/bin
  Successfully uninstalled pycrypto
    Installing pyrsa-decrypt-bigfile script to /usr/bin
</syntaxhighlight>
   Running setup.py install for pyasn1
<syntaxhighlight lang='console'>
Successfully installed Crypto rsa pyasn1
[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...
Cleaning up...
</source>
</syntaxhighlight>
 
==확인 2==
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import Crypto; print( Crypto.__version__ );'
2.6.1
</syntaxhighlight>
 
==같이 보기==
*[[pycrypto 업그레이드]]


[[분류: Python 오류]]
[[분류: ImportError]]
[[분류: import Crypto]]

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