0
$\begingroup$

Rosanswers logo

I tried to install relaunch roscore on Ubuntu 18.04 but got the following error. Any advice is greatly appreciated.

Traceback (most recent call last):
  File "/opt/ros/melodic/bin/roscore", line 72, in <module>
    import roslaunch
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/__init__.py", line 52, in <module>
    from . import param_dump as roslaunch_param_dump
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/param_dump.py", line 40, in <module>
    import roslaunch.config
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/config.py", line 45, in <module>
    import rospkg.distro
  File "/usr/lib/python2.7/dist-packages/rospkg/distro.py", line 44, in <module>
    import yaml
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 284
    class YAMLObject(metaclass=YAMLObjectMetaclass):
                              ^
SyntaxError: invalid syntax

Originally posted by SlowAnnealing on ROS Answers with karma: 1 on 2021-07-27

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It appears you have not installed apt package python-yaml, and/or your environment variable PYTHONPATH is not right. If it has any entries for python3 in it, that going to cause you headaches.


Originally posted by Mike Scheutzow with karma: 4903 on 2021-07-27

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by SlowAnnealing on 2021-07-27:
Thanks for your suggestion, Mike. I believe my conda environment disrupt the ROS. The following line in ~/.bashrc was commented out but the error persist even after python-yaml is confirmed installed in my machine. #export PYTHONPATH="/usr/lib/python3/dist-packages:$PYTHONPATH"

Since there is an entry for python3, the only option is reinstall ROS Melodic. Correct?

Comment by Mike Scheutzow on 2021-07-27:
You shouldn't have to. Try deleting the PYTHONPATH variable and source setup.bash again:

unset PYTHONPATH
source /opt/ros/melodic/setup.bash

Comment by SlowAnnealing on 2021-07-27:
I appreciate your expertise, Mike. Your solution works perfect without any impact on conda.

Comment by gvdhoorn on 2021-07-28:
I'm happy this got resolved, but please be mindful of posting duplicates.

See #q221035, #q11479 and perhaps even #q9791.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.