Python 模块:安装 bitarray 时遇到问题

Python 模块:安装 bitarray 时遇到问题

我不确定为什么我bitarray在 Ubuntu 8.10 机器上安装 Python 模块时遇到困难。

dan@Tower:~/py$ tar xzf bitarray-0.3.5.tar.gz
dan@Tower:~/py$ cd bitarray-0.3.5
dan@Tower:~/py/bitarray-0.3.5$
dan@Tower:~/py/bitarray-0.3.5$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.5
creating build/lib.linux-i686-2.5/bitarray
copying bitarray/test_bitarray.py -> build/lib.linux-i686-2.5/bitarray
copying bitarray/__init__.py -> build/lib.linux-i686-2.5/bitarray
running build_ext
building 'bitarray._bitarray' extension
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/bitarray
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c bitarray/_bitarray.c -o build/te
mp.linux-i686-2.5/bitarray/_bitarray.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.5/bitarray/_bitarray.o -o build/lib.linux-i686-2.5/bitarray/_bitarray.so
running install_lib
creating /usr/lib/python2.5/site-packages/bitarray
error: could not create '/usr/lib/python2.5/site-packages/bitarray': Permission denied


dan@Tower:~/py/bitarray-0.3.5$ sudo python setup.py install
[sudo] password for dan: 
running install
running build
running build_py
running build_ext
running install_lib
creating /usr/lib/python2.5/site-packages/bitarray
copying build/lib.linux-i686-2.5/bitarray/_bitarray.so -> /usr/lib/python2.5/site-packages/bitarray
copying build/lib.linux-i686-2.5/bitarray/test_bitarray.py -> /usr/lib/python2.5/site-packages/bitarray
copying build/lib.linux-i686-2.5/bitarray/__init__.py -> /usr/lib/python2.5/site-packages/bitarray
byte-compiling /usr/lib/python2.5/site-packages/bitarray/test_bitarray.py to test_bitarray.pyc
byte-compiling /usr/lib/python2.5/site-packages/bitarray/__init__.py to __init__.pyc
running install_egg_info
Writing /usr/lib/python2.5/site-packages/bitarray-0.3.5.egg-info


dan@Tower:~/py/bitarray-0.3.5$ python -c 'import bitarray; bitarray.test()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "bitarray/__init__.py", line 13, in <module>
    from _bitarray import _bitarray, bits2bytes, _sysinfo
ImportError: No module named _bitarray

答案1

模块已正确安装,但如果您位于 中,它会尝试导入本地版本~/py/bitarray-0.3.5。这不起作用,因为您的源代码树中没有 _bitarray.so(您需要python build_ext -i使其工作)。只需转到其他目录并从那里运行 python,它就会工作。

相关内容