0
$\begingroup$

Rosanswers logo

Hi!

I am trying to install ROS on Ubuntu 11.04. I tried to follow howtos and similar documents, but it didn't work for me. My main goal is to get a working system with MORSE, ROS and Blender. I managed to install Blender and MORSE, they work together. I also installed python 3.2.1 and ROS electric from the repositories. Now, when I try to run roscore or roslaunch I get the following errors:

Traceback (most recent call last):
  File "/opt/ros/electric/ros/bin/roslaunch", line 2, in <module>
    from ros import roslaunch
ImportError: cannot import name roslaunch

I thought that it is maybe because I hadn't yet installed the rosinstall software. So I tried to install it from the repositories using sudo apt-get install python-rosinstall as it was written here: http://www.ros.org/doc/api/rosinstall/html/ Unfortunately, it seems to only work for fuerte not for electric, so I tried to install it using pip:

sudo pip install -U rosinstall vcstools

Then I try to run rosinstall, but I always get errors like this:

    Traceback (most recent call last):
  File "/home/zsarosi/.local/bin/rosinstall", line 5, in <module>
    from rosinstall.rosinstall_cli import rosinstall_main
  File "/home/zsarosi/.local/lib/python2.7/site-packages/rosinstall/__init__.py", line 33, in <module>
    import rosinstall.helpers
  File "/home/zsarosi/.local/lib/python2.7/site-packages/rosinstall/helpers.py", line 35, in <module>
    from rosinstall.config_elements import SetupConfigElement
  File "/home/zsarosi/.local/lib/python2.7/site-packages/rosinstall/config_elements.py", line 38, in <module>
    from vcstools import VcsClient
  File "/home/zsarosi/.local/lib/python2.7/site-packages/vcstools/__init__.py", line 45, in <module>
    from vcstools.tar import TarClient
  File "/home/zsarosi/.local/lib/python2.7/site-packages/vcstools/tar.py", line 52, in <module>
    import yaml
  File "/usr/local/lib/python3.2/dist-packages/yaml/__init__.py", line 284
    class YAMLObject(metaclass=YAMLObjectMetaclass):
                              ^
SyntaxError: invalid syntax

Since it shows directories with the version 2.7 in them instead of 3.2, I suspect that my PYTHONPATH environmental variable is still missing something, at the moment it looks like this:

/opt/morse/lib/python3/site-packages:/opt/ros/electric/ros/core/roslib/src::/usr/local/lib/python3.2:/usr/local/lib/python3.2/site-packages:/usr/local/lib/python3.2/dist-packages:/home/zsarosi/builds/morse/bindings/pymorse:/opt/morse/lib/python3/dist-packages:/opt/ros/electric/ros/core/roslib/src

I am stucked now. Can anyone please help me?


Originally posted by zoltan on ROS Answers with karma: 11 on 2012-10-29

Post score: 0


Original comments

Comment by Po-Jen Lai on 2012-10-29:
Do you need python 3.2?Try install python2.7?

Comment by Lorenz on 2012-10-29:
Blender needs python 3 and making morse work with ros is definitely non-trivial.

Comment by Po-Jen Lai on 2012-10-29:
Sorry for the incorrect comment.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

First, rosinstall is only a tool to download sources from version control. It makes life easier when you want to download sources, and that's all. So it will not solve your earlier problem.

Traceback (most recent call last):
  File "/opt/ros/electric/ros/bin/roslaunch", line 2, in <module>
    from ros import roslaunch
ImportError: cannot import name roslaunch

This means your the roslaunch python libraries are not on your PYTHONPATH. To get them on your pythonpath, it is usually sufficient to run:

source /opt/ros/electric/setup.bash

before attempting to run roscore or any ros node or tool. Since your questio ndoes not show what exactly you have tried to run when getting the error message, we can only guess what went wrong.

As to rosinstall, we have not finalized python3 compatibility. So it might be best for you to not use it for now, unless you manage to run it using python2. getting that to run might be good for a different question.

(One way to run cleanly things using python2 in Ubuntu is to use virtualenv.

Note that apparently you are running rosinstall using python2.7, therefore when it tires to use yaml for python3, you get the invalid syntax error. So what you would need is to create a virtualenv for python2.7, install yaml using pip to that virtualenv, then using that virtualenv run rosinstall. Then rosinstall would not use python3 yaml, but python2 yaml from your environment. Note that for this approach, you would probably also have to install other python libraries for python2.7.)


Originally posted by KruseT with karma: 7848 on 2012-10-30

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$
0
$\begingroup$

Rosanswers logo

Thanks KruseT for the answer. In the meantime I have managed to come up with a simple PYHTONPATH that works with ros and morse too.

/opt/ros/electric/ros/core/roslib/src:/opt/morse/lib/python3/dist-packages

In my .bashrc file I have the following regarding morse and ROS:

source /opt/ros/electric/setup.bash
export PYTHONPATH=$PYTHONPATH:$ROS_ROOT/core/roslib/src

#   
# MORSE Setup
#
export MORSE_ROOT=/opt/morse
export PATH=/opt/morse/bin:${PATH}
export MORSE_BLENDER=/opt/blender/bin/blender
#export PYTHONPATH=/opt/morse/lib/python3/site-packages:${PYTHONPATH}

export PYTHONPATH=$PYTHONPATH:/opt/morse/lib/python3/dist-packages
source /home/myuser/electric_workspace/setup.bash

Now it seems to work:

  • I can run roscore and roslaunch without any errors
  • I can run rosinstall without any error message
  • I can run morse check

However, I don't know yet, whether it works with other software, I haven't fully tested it.


Originally posted by zoltan with karma: 11 on 2012-10-31

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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