2014-02-10 8 views
0

내가 pypy를 실행하고 및 sys.path에 bitarray 라이브러리의 경로를 추가 한 후 나는 아직도 모듈 가져올 수 없습니다 : bitarray 가져 오기 (적성에서 설치 CPython과) 일반 파이썬에서pypy를 사용하여 비트 배열을 가져 오는 방법은 무엇입니까?

Python 2.7.3 (87aa9de10f9ca71da9ab4a3d53e0ba176b67d086, Feb 10 2014, 05:26:49) 
[PyPy 2.2.1 with GCC 4.7.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
And now for something completely different: ``every VM should come with neural 
network trained to recognize microbenchmarks and randomly fluctuate them 
+/-9000%'' 
>>>> import sys 
>>>> sys.path.append('/usr/local/lib/python2.7/dist-packages/') 
>>>> sys.path.append('/usr/local/lib/python2.7/dist-packages/bitarray/') 
>>>> import bitarray 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/bitarray/__init__.py", line 11, in <module> 
    from bitarray._bitarray import _bitarray, bitdiff, bits2bytes, _sysinfo 
ImportError: No module named bitarray._bitarray 

것은 '잘 나는 천국 작동 pip로 모듈을 설치 한 후에 모듈을 수정했습니다. 여기 뭐가 잘못 됐니?

$ls /usr/local/lib/python2.7/dist-packages/bitarray/ 
_bitarray.so __init__.py __init__.pyc test_bitarray.py test_bitarray.pyc 

UPDATE

pypy에 대한 VIRTUALENV를 만들고 써니 핍과 bitarray 설치 한 후 나는 아직도 얻을 제안 :

그냥 경우에 당신은 여기 bitarray 디렉토리의 내용입니다 필요 ImportError를 :

$ ls my-pypy-env/site-packages/bitarray 
_bitarray.pypy-22.so __init__.py __init__.pyc test_bitarray.py test_bitarray.pyc 


$ cd my-pypy-env/ 
~/my-pypy-env$ ./bin/activate 
~/my-pypy-env$ pypy 
Python 2.7.3 (87aa9de10f9ca71da9ab4a3d53e0ba176b67d086, Feb 10 2014, 05:26:49) 
[PyPy 2.2.1 with GCC 4.7.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
And now for something completely different: ``__xxx__ and __rxxx__ vs operation 
slots: particle quantum superposition kind of fun'' 
>>>> import sys 
>>>> sys.path.append('/home/sofia/my-pypy-env/site-packages/bitarray') 
>>>> import bitarray 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named bitarray 

업데이트 2

맑음의 해결책은 정확합니다. 새로운 문제가 /site-packages/ 대신 /site-packages/bitarray 이 추가되었습니다. 나는 virtualenv가 경로에 이것을 자동으로 추가 할 것이지만 그것이 가지고있는 것처럼 보일 것이다.

답변

2

_bitarray 모듈은 C에 직접 작성된 CPython 확장 프로그램처럼 보입니다. CPython 확장 모듈은 이 아니며은 변경하지 않고 PyPy에서 직접 작동합니다. PyPy 호환 버전의 모듈을 설치하거나 필요한 변경을 수동으로 수행해야합니다.

http://doc.pypy.org/en/latest/faq.html#module-xyz-does-not-work-with-pypy-importerror

http://doc.pypy.org/en/latest/faq.html#do-cpython-extension-modules-work-with-pypy

+0

이 있습니까 : 여기

# If pypy is installed globally /path/to/pypy/pypy-2.1/bin/pip install bitarray # If using virtualenv source /path/to/virtualenv/env/bin/activate pip install bitarray 

은이 문제에 대한 PyPy 자주 묻는 질문에서 링크의 커플 :

다음과 같은 명령을 사용 pypy 호환 버전을 설치하려면 비트 배열이 C로 작성되었는지 확인하는 방법은 무엇입니까? –

+0

전체 비트 배열이 아니라 ImportError의 하위 모듈'bitarray._bitarray'. 네, 그렇습니다 : 파일'_bitarray.so'의'.so' 확장자를보십시오. –

+0

위의 링크에서 설명한대로 virtualenv에서'pip install bitarray'를 실행하면 제대로 작동하는 것 같습니다. C 코드를 성공적으로 컴파일하므로 sys.path를 해킹 할 필요가 없습니다. –