我正在尝试在 Debian Jessie 上安装 ROS,但在运行sudo rosdep init
. 我遵循的说明位于此 URL ( http://wiki.ros.org/kinetic/Installation/Source )。由于某些库冲突,我是从源代码安装而不是通过他们的存储库安装的。
运行sudo rosdep init
结果如下。
Traceback (most recent call last):
File "/usr/bin/rosdep", line 3, in <module>
from rosdep2.main import rosdep_main
File "/usr/lib/python2.7/dist-packages/rosdep2/__init__.py", line 40, in <module>
from .installers import InstallerContext, Installer, \
File "/usr/lib/python2.7/dist-packages/rosdep2/installers.py", line 35, in <module>
from rospkg.os_detect import OsDetect
File "/usr/lib/python2.7/dist-packages/rospkg/__init__.py", line 42, in <module>
from .rospack import expand_to_packages, get_package_name, \
File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 35, in <module>
from xml.etree.cElementTree import ElementTree
File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
from _elementtree import *
ImportError: PyCapsule_Import could not import module "pyexpat"
我认为这是python根本找不到模块,所以我查看了它的位置和python的路径,但无济于事。
[jwerner5@rockhopper:~ ] $$ find / -name pyexpat*
/usr/include/python2.7/pyexpat.h
/usr/include/python3.4m/pyexpat.h
/usr/share/jython/Lib/pyexpat.py
/usr/share/jython/Lib/pyexpat$py.class
/usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/wx-3.0-gtk2']
所以它在路径中。接下来我运行了一个strace -e open rosdep
只是确保它正在找到文件。这是它的输出。看起来它找到了文件然后立即关闭它。这是相关的部分。
open("/usr/lib/python2.7/lib-tk/pyexpat.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/lib-tk/pyexpat.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so", O_RDONLY) = 9
open("/usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 10
Traceback (most recent call last):
这个问题(ImportError: PyCapsule_Import could not import module "pyexpat")建议尝试重命名库或重新安装它。我已经尝试了这两件事,但都没有奏效。有没有人有任何想法?
编辑:自发布以来,按照forax的说明,我尝试设置LD_LIBRARY_PATH,在python shell中手动导入pyexpat,并查看了ldd for pyexpat的输出。
手动导入pyexpat
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyexpat
.
ldd
在 pyexpat 库上运行
[jwerner5@rockhopper:~ ] $$ ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffc069da000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f7214382000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7214165000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7213db9000)
/lib64/ld-linux-x86-64.so.2 (0x000055fe01ce4000)