ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
0

importing PIL into a rosnode

asked 2011-04-22 09:10:18 -0600

jrieffel gravatar image

updated 2014-01-28 17:09:34 -0600

ngrennan gravatar image

when I have the line

"from PIL import Image"

in a node, I get the following error when running my node via rosrun

"ImportError: No module named PIL"

of course, PIL is installed in

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL

but is not an ROS library. How can I change my manifest.xml to find PIL? If I understand correctly, rosrun clobbers my existing PYTHONPATH (when running python I can import PIL just fine).

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-04-25 05:26:26 -0600

jrieffel gravatar image

I resolved it by explicitly putting PIL in my .bashrc's PYTHONPATH

oddly, however, python from the command line runs python 2.6.6, but rosrun on a python node somehow invokes python 2.6.1

edit flag offensive delete link more
0

answered 2011-04-23 06:26:48 -0600

kwc gravatar image

This sounds like an issue with a MacPorts setup. On OS X, it is often necessary to run the python_select tool to use the version of Python managed by MacPorts instead.

The simplest test of your setup is:

$ python
>>> import PIL

rosrun does not alter your PYTHONPATH, and there are no modifications necessary in ROS to use a system-installed Python library. rosrun is nothing more than a convenience tool for locating executables and running them. You can verify by manually running the script instead w/o rosrun.

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: 2011-04-22 09:10:18 -0600

Seen: 347 times

Last updated: Apr 25 '11