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

ImportError: No module named yaml

asked 2011-10-14 19:14:51 -0600

Kamal gravatar image

After i recently installed a new version of python, nothing is working in ros. Every time i get import error saying no yaml found. For example, when i run roscore, i get an error as follows:

Traceback (most recent call last):

File "/opt/ros/diamondback/ros/bin/roscore", line 34, in <module>

from ros import roslaunch

File "/opt/ros/diamondback/ros/core/roslib/src/ros/__init__.py", line 41, in <module>

import roslib

File "/opt/ros/diamondback/ros/core/roslib/src/roslib/__init__.py", line 50, in <module>

from roslib.launcher import load_manifest

File "/opt/ros/diamondback/ros/core/roslib/src/roslib/launcher.py", line 45, in <module>

import roslib.manifest

File "/opt/ros/diamondback/ros/core/roslib/src/roslib/manifest.py", line 46, in <module>

import roslib.packages

File "/opt/ros/diamondback/ros/core/roslib/src/roslib/packages.py", line 58, in <module>

import roslib.os_detect

File "/opt/ros/diamondback/ros/core/roslib/src/roslib/os_detect.py", line 49, in <module>

import yaml

ImportError: No module named yaml

.............................................................................................

And yes, i have installed yaml.

"sudo apt-get install python-yaml" gives

Reading package lists... Done

Building dependency tree

Reading state information... Done

python-yaml is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 107 not upgraded.

.............................................................................................

What could be the problem?

edit retag flag offensive close merge delete

Comments

It sounds like your current version of python doesn't have the yaml module installed. Which distribution and which version of python are you using?
ahendrix gravatar image ahendrix  ( 2011-10-14 19:40:28 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2011-10-15 10:29:07 -0600

tfoote gravatar image

When you install the new version of python you need to install the version of python-yaml for that version. Python libraries are installed into different locations for different versions. Apt-get install will only install the yaml module for your default python.

If your default python is 2.6 it will install into /usr/lib/python2.6 but if you're using 2.7 it will install need the yaml module installed in /usr/lib/python2.7 which is the python 2.7 version of the library.

edit flag offensive delete link more

Comments

I havent separately installed yaml, it came along with python installation. Also I see yaml folders in /usr/lib/python2.6/dist-packages as well as /usr/lib/python2.7/dist-packages. So i am guessing that yaml is installed for 2.7 also. now what does that mean?
Kamal gravatar image Kamal  ( 2011-10-15 16:17:40 -0600 )edit
1
You need tp provide more information on how you "installed a new version of python" for us to help you any more. It sounds like you did that incorrectly. Note, I'm just guessing at python versions as you have not mentioned what you're using. Please see http://www.ros.org/wiki/Support
tfoote gravatar image tfoote  ( 2011-10-16 06:38:19 -0600 )edit

If you've yaml present in more than a folder, you've to figure out which is the version you've to use (related to the version of python), and then add that folder in the PYTHONPATH. At least is what I did to solve the problem.

Ruthven gravatar image Ruthven  ( 2014-05-22 23:33:08 -0600 )edit
0

answered 2011-10-15 06:41:32 -0600

Chad Rockey gravatar image

This is probably not the answer to your direct problem, but for completeness, I'd like to point out that I get this error when I'm working in a file system I just rewrote.

Ex: I have a destructive distribution policy that rm -rf 'stacks' and then the file system is recreated. When this happens, if I do not rospack profile and roscd 'something', I get the ImportError: No module named yaml error.

Sorry this probably won't answer your specific case. You should stick with the python distribution installed with your distro/ROS. Can you revert back to the old python version?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-10-14 19:14:51 -0600

Seen: 53,514 times

Last updated: Oct 15 '11