2014-01-14 10 views
3

pycrypto를 설치하고 사용하려고합니다. 설치 중에 오류가 발생하지 않으므로 더 이상 문제를 해결할 수 없습니다.PyCrypto가 OSX 매버릭스에서 작동하지 않음

'test'를 실행하고 다음과 같은 오류가 발생했지만 해결 방법을 찾을 수 없습니다.

참고로 XCode 및 명령 줄 도구가 설치되어 있습니다. 당신은 MacPorts를 통해 파이썬을 실행하면

mac:pycrypto-2.6.1 rajivvishwa$ export ARCHFLAGS='-arch i386 -arch x86_64' 
mac:pycrypto-2.6.1 rajivvishwa$ sudo python setup.py build 
running build 
running build_py 
running build_ext 
running build_configure 
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath. 
mac:pycrypto-2.6.1 rajivvishwa$ sudo python setup.py install 
running install 
running build 
running build_py 
running build_ext 
running build_configure 
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath. 
running install_lib 
running install_egg_info 
Removing /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pycrypto-2.6.1-py2.6.egg-info 
Writing /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pycrypto-2.6.1-py2.6.egg-info 

mac:pycrypto-2.6.1 rajivvishwa$ sudo python setup.py test 
running test 
.......................................................................................................................................................................................................... SelfTest: You can ignore the RandomPool_DeprecationWarning that follows. 
build/lib.macosx-10.9-intel-2.6/Crypto/Util/randpool.py:40: RandomPool_DeprecationWarning: This application uses RandomPool, which is BROKEN in older releases. See http://www.pycrypto.org/randpool-broken 
    RandomPool_DeprecationWarning) 
..........E................... 
====================================================================== 
ERROR: Test that mpzToLongObj and longObjToMPZ (internal functions) roundtrip negative numbers correctly. 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "build/lib.macosx-10.9-intel-2.6/Crypto/SelfTest/Util/test_number.py", line 283, in test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ 
    k = number._fastmath.rsa_construct(n, e) 
AttributeError: 'NoneType' object has no attribute 'rsa_construct' 

---------------------------------------------------------------------- 
Ran 1033 tests in 150.196s 

FAILED (errors=1) 
Traceback (most recent call last): 
    File "setup.py", line 456, in <module> 
    core.setup(**kw) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 152, in setup 
    dist.run_commands() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 975, in run_commands 
    self.run_command(cmd) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 995, in run_command 
    cmd_obj.run() 
    File "setup.py", line 336, in run 
    SelfTest.run(module=moduleObj, verbosity=self.verbose, stream=sys.stdout, config=self.config) 
    File "build/lib.macosx-10.9-intel-2.6/Crypto/SelfTest/__init__.py", line 74, in run 
    raise SelfTestError("Self-test failed", result) 
Crypto.SelfTest.SelfTestError: ('Self-test failed', <unittest._TextTestResult run=1033 errors=1 failures=0>) 

mac:pycrypto-2.6.1 rajivvishwa$ python 
Python 2.6.8 (unknown, Aug 25 2013, 00:04:29) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import Crypto 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named Crypto 

답변

3

,

sudo port install py27-crypto 

은 다음 다음 C 컴파일러와 같은 '연타'설정 최신 OSX에 pycrypto을 설치하려는 경우 암호화가

+0

나는 pycrypto가 python2.7에 설치되었고 내 기본 파이썬에는없는 것처럼 보였다. macports와 함께 기본 파이썬에 설치할 수 있습니까? – rajivvishwa

+0

아니오 macports와 함께 할 수 없습니다. macports는 대체 파이썬 용입니다. 기본 파이썬의 경우 brew install을 시도해야합니다. – bistaumanga

+0

mavericks 업데이트로 인해 brew가 깨졌습니다. http://stackoverflow.com/questions/19635804. – rajivvishwa

2

작동합니다 가져올 시도하는 configure가 사용합니다. 이것은 CC 환경 변수를 통해 수행됩니다.

방법

는 VIRTUALENV이를 디버깅하는 :

sudo easy_install virtualenv==1.10.1 
virtualenv venv 
export CC=clang 
venv/bin/pip install --no-clean pycrypto 
cat venv/build/pycrypto/config.log 
0

이 맥 파일 시스템에서 소문자 구분 환경처럼 보인다. 리눅스는 대소 문자를 구별하며, 패키지 소유자가 리눅스를 사용하여 패키지를 생성했다.

먼저 암호화 패키지를 설치했습니다 (최후의 수단으로 sudo에 사용).

sudo pip install pycrypto 

pip install crypto 

그런 다음 소문자 패키지 이름의 이름을 대문자로 바꿉니다.

/path/to/venv/lib/python2.7/site-packages에서 crypto에서 Crypto으로 이름을 변경하십시오.