Ask Your Question
1

ModuleNotFoundError: No module named 'error'

asked 2019-02-07 06:23:33 -0500

joesherman gravatar image

updated 2019-02-07 06:26:56 -0500

gvdhoorn gravatar image

Hi, I am a beginner in Python, Ros and Ubuntu and am having difficulties in running the first program on ROS, i.e. listener.py I am running Ros melodic in Ubuntu 18.04 The following error report comes up on running "rosrun hello_world listener.py"

joseph@joseph-Inspiron-5558:~$ rosrun hello_world talker.py 
Traceback (most recent call last):
  File "/home/joseph/catkin_ws/src/hello_world/scripts/talker.py", line 39, in <module>
    import rospy
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 5, in <module>
    import genpy
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 44, in <module>
    import yaml
  File "/usr/lib/python2.7/dist-packages/yaml/__init__.py", line 2, in <module>
    from error import *
**ModuleNotFoundError: No module named 'error'**
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
**AttributeError: module 'enum' has no attribute 'IntFlag'**

Original exception was:
Traceback (most recent call last):
  File "/home/joseph/catkin_ws/src/hello_world/scripts/talker.py", line 39, in <module>
    import rospy
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 5, in <module>
    import genpy
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 44, in <module>
    import yaml
  File "/usr/lib/python2.7/dist-packages/yaml/__init__.py", line 2, in <module>
    from error import *
**ModuleNotFoundError: No module named 'error'**

The text in bold are the error messages and they seem to be something related to the version conflict in the multiple installations of python.

Any help in resolving this matter would be appreciated Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-02-07 07:21:35 -0500

joesherman gravatar image

The issue has been resolved. I checked the script and it had "#!/usr/bin/env python3" in it, changing it to "#!/usr/bin/env python" resolved the issue. Though i would still like to know what is the cause of this, and what this change means !

edit flag offensive delete link more
0

answered 2020-03-29 11:31:18 -0500

attackordie gravatar image

updated 2020-03-29 12:06:49 -0500

gvdhoorn gravatar image

Late answer but I had a similar issue and hope this answer helps others. You are correct in that it's related to the multiple installations of python. It seems related to the package 'enum' that ROS melodic installs causing breaking issues on my host computer. See this issue for some further guidance module 'enum' has no attribute 'IntFlag' #1582

Make sure the first line in your script

#!/user/bin/env python<your version ROS uses>

matches your ROS version. I'm stuck using python2.7 with ROS so I have !/usr/bin/env python2 as the first line in my python script.

Keep in mind yours will likely different.

Also my host computer is using python 3.7 so this leads to issues running the script. This link my help some if you are dealing with $PYTHONPATH issues. I ended up setting the path in my bash.rc file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-02-07 06:23:33 -0500

Seen: 7,712 times

Last updated: Mar 29 '20