尽管找到pythonpath,但由于找不到模块错误而无法运行python文件

时间:2019-07-18 09:51:37

标签: python-3.x python-2.7 ros

我一直试图使用rosrun命令运行python文件,但是不幸的是,由于一个名为rospkg的软件包,我没有发现此模块错误。直到前一天,一切正常,但昨天,ubuntu18.04进行了一些更新,其中也有针对ubuntu base的更新,因为该更新我有此错误。

我尝试检查是否已安装相应的python-rospkg,并且它说我已经有了最新版本。我也用    echo $PYTHONPATH 要检查来源路径并且来源正确,我不确定是什么导致了此错误。

错误如下       Traceback (most recent call last File "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 5, in <module> import roslib File "/opt/ros/melodic/lib/python2.7/dist- packages/roslib/__init__.py", line 50, in <module> from roslib.launcher import load_manifest File "/opt/ros/melodic/lib/python2.7/dist- packages/roslib/launcher.py", line 42, in <module> import rospkg ModuleNotFoundError: No module named 'rospkg'

我的shebang如下,       #!/usr/bin/python3 当我尝试通过将shebang更改为来运行文件时       #!/usr/bin/python2.7 我收到以下错误        Traceback (most recent call last): File "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 3, in <module> import tensorflow as tf ImportError: No module named tensorflow

我已经使用pip安装安装了tensorflow版本1.14。谁能帮我解决这个错误。预先感谢

编辑:

当我尝试安装python-rospkg时,我手动尝试将python路径设置为/usr/lib/python2.7/dist-packages,它说它已安装在该位置。这样做我导入张量流时出错,错误是

 `Traceback (most recent call last):
  File 
 "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 
  3, in <module>
 import tensorflow as tf
 File "/home/microbot/.local/lib/python3.6/site- 
 packages/tensorflow/__init__.py", line 22, in <module>
 import inspect as _inspect
 File "/usr/lib/python3.6/inspect.py", line 41, in <module>
 import linecache
 File "/usr/lib/python3.6/linecache.py", line 11, in <module>
 import tokenize
 File "/usr/lib/python3.6/tokenize.py", line 33, in <module>
 import re
 File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:`

0 个答案:

没有答案