ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

catkin_make error: ImportError: No module named 'error'

asked 2019-12-19 01:16:36 -0500

RoboNerd gravatar image

updated 2019-12-20 05:28:34 -0500

gvdhoorn gravatar image

So, i am a beginner in ROS i have this error every time i do a catkin_make

Traceback (most recent call last):
 File "/opt/ros/kinetic/share/genpy/cmake/../../../lib/genpy/genmsg_py.py", line 44, in <module>
    import genpy.generator
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/kinetic/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 *
ImportError: No module named 'error'

and after a lot of googling i figured that the problem is because of the PYTHONPATH.

so to check my PYTHONPATH is did

echo $PYTHONPATH

and i got

/home/username/catkin_ws/devel/lib/python3/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages

i think the reason behind the problem is the "/python3/dist-package" how do i change it ? i tried adding the path manually in ~/.bashrc

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

but still every time i doecho $PYTHONPATH i get

/opt/ros/kinetic/lib/python2.7/dist-packages:/home/username/catkin_ws/devel/lib/python3/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

how do i solve this ? Please HELP !

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-12-20 06:02:24 -0500

RoboNerd gravatar image

So i was able to solve my error by deleting the content inside the BUILD folder and then do catkin_make. So the problem is solved for now and also there was a folder named name python3 in ~/catkin_ws/devel/lib/python3 which reappeared every time i do catkin_make no matter how many times i deleted the folder manually. This time i deleted and it never reappeared. I even removed the manually added PYTHONPATH in my ~/.bashrc so now the echo $PYTHONPATH is /home/username/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages which I believe is the correct PYTHONPATH. Thanks @gvdhoorn & @Abhishekpg111 for your suggestions.

edit flag offensive delete link more
1

answered 2019-12-19 10:12:15 -0500

Abhishekpg gravatar image

try adding export PYTHONPATH="/opt/ros/kinetic/lib/python2.7/dist-packages"

edit flag offensive delete link more

Comments

it doesn't solve the issue, the error persists. However every time i do echo $PYTHONPATH i get /opt/ros/kinetic/lib/python2.7/dist-packages

RoboNerd gravatar image RoboNerd  ( 2019-12-20 04:07:48 -0500 )edit

Yes, I would not have expected this to work.

@RoboNerd: can you explain why we see mentions of Python 3 in your PYTHONPATH? Kinetic does not support Python 3 natively, and while it is possible to use it, problems like these are typically seen when things are not correctly configured.

Do you have Anaconda installed by any chance?

gvdhoorn gravatar image gvdhoorn  ( 2019-12-20 04:10:07 -0500 )edit
1

No, i have not installed Anaconda and i don't know how there are mentions of Python 3 in my PYTHONPATH But i was able to rectify my error by deleting the content inside the BUILD folder and then do catkin_make. So the problem is solved for now and also there was a folder named name python3 in ~/catkin_ws/devel/lib/python3 which reappeared every time i do catkin_make no matter how many times i deleted the folder manually. This time i deleted and it never reappeared. I even removed the manually added PYTHONPATH in my ~/.bashrc so now the echo $PYTHONPATH is /home/username/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages which I believe is the correct PYTHONPATH. Thanks @gvdhoorn & @Abhishekpg111 for your suggestions.

RoboNerd gravatar image RoboNerd  ( 2019-12-20 05:23:09 -0500 )edit

Ok. Good to hear things now work.

Suggestion: post your last comment as an answer and accept your own answer.

I've unchecked the answer by @Abhishekpg111 as it's not the real answer.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-20 05:25:51 -0500 )edit

sure, I'll do that.

RoboNerd gravatar image RoboNerd  ( 2019-12-20 05:59:26 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-12-19 01:16:36 -0500

Seen: 1,938 times

Last updated: Dec 20 '19