The reason this error occurs is because Python packages in /opt are added to PYTHONPATH environment variable BUT for ones in /usr, path does not exist in PYTHONPATH variable. The python-rospkg gets installed in /usr by default. So you just need following line in .bashrc to fix this:
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages
ok,it can work for me
修复Python ROSPKG路径错误
本文介绍了一种常见的Python环境变量问题,即ROS相关包在默认安装位置(/usr)未被PYTHONPATH识别而导致的错误,并提供了解决方案:通过在.bashrc文件中添加export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages来修正。
671





