Ask Your Question

roslaunch changes my PYTHONPATH

asked 2011-11-28 04:39:07 -0500

Constantin S gravatar image

updated 2014-01-28 17:10:53 -0500

ngrennan gravatar image

Hello all, I am running a python script from a callback. When I run my test code from my shell, I have my environment variables (from my bashrc), more specifically my PYTHONPATH. However, when I do a roslaunch, PYTHONPATH is only pointing to the ros python modules. Could anyone offer any suggestions? Do I need to use the <env> tags in the launch file? Is roslaunch overwriting environment variables or is it running in a different shell? Thank you


Edit: I am getting this runtime error as well. If you notice, there is a missing symbol _Py_ZeroStruct. I have seen similar error messages and they've always been related to me not linking a library correctly. In this case it seems the python library may not be linking correctly. In my example program, I simply use:

In the CMakeList.txt, I use:
 target_link_libraries(ExtractionController python2.6) 
I have a feeling, ROS is forcing a bad link somewhere though. Has anyone experienced this? Thank you. Here is a print out of the runtime error:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/numpy/", line 130, in <module>
    import add_newdocs
  File "/usr/lib/python2.6/dist-packages/numpy/", line 9, in <module>
    from lib import add_newdoc
  File "/usr/lib/python2.6/dist-packages/numpy/lib/", line 4, in <module>
    from type_check import *
  File "/usr/lib/python2.6/dist-packages/numpy/lib/", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/usr/lib/python2.6/dist-packages/numpy/core/", line 5, in <module>
    import multiarray
ImportError: /usr/lib/python2.6/dist-packages/numpy/core/ undefined symbol: _Py_ZeroStruct
Traceback (most recent call last):
  File "/home/constantin/workspace/OpenRAVE/src/", line 3, in <module>
    from openravepy import *
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/", line 35, in <module>
    openravepy_currentversion = loadlatest()
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/", line 16, in loadlatest
    return _loadversion('_openravepy_')
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/", line 19, in _loadversion
    mainpackage = __import__("openravepy", globals(), locals(), [targetname])
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/_openravepy_/", line 29, in <module>
    from openravepy_int import *
ImportError: numpy.core.multiarray failed to import
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-28 05:43:15 -0500

Constantin S gravatar image

I have managed to find a solution for my first problem. Using the following code inside a launch file allows me to pass in my PYTHONPATH. I am assuming this will work for all other environment variables that are being lost as well:

<env name="PYTHONPATH" value="$(env PYTHONPATH)" />

I hope this helps.

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


Asked: 2011-11-28 04:39:07 -0500

Seen: 862 times

Last updated: Nov 28 '11