Rosanswers logo

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 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/__init__.py", line 130, in 
    import add_newdocs
  File "/usr/lib/python2.6/dist-packages/numpy/add_newdocs.py", line 9, in 
    from lib import add_newdoc
  File "/usr/lib/python2.6/dist-packages/numpy/lib/__init__.py", line 4, in 
    from type_check import *
  File "/usr/lib/python2.6/dist-packages/numpy/lib/type_check.py", line 8, in 
    import numpy.core.numeric as _nx
  File "/usr/lib/python2.6/dist-packages/numpy/core/__init__.py", line 5, in 
    import multiarray
ImportError: /usr/lib/python2.6/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct
Traceback (most recent call last):
  File "/home/constantin/workspace/OpenRAVE/src/grasp_behavior_2.py", line 3, in 
    from openravepy import *
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/__init__.py", line 35, in 
    openravepy_currentversion = loadlatest()
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/__init__.py", line 16, in loadlatest
    return _loadversion('_openravepy_')
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/__init__.py", line 19, in _loadversion
    mainpackage = __import__("openravepy", globals(), locals(), [targetname])
  File "/home/constantin/workspace/rospackages/openrave/lib/python2.6/site-packages/openravepy/_openravepy_/__init__.py", line 29, in 
    from openravepy_int import *
ImportError: numpy.core.multiarray failed to import

Originally posted by Constantin S on ROS Answers with karma: 296 on 2011-11-28

Post score: 0


1 Answer 1


Rosanswers logo

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.

Originally posted by Constantin S with karma: 296 on 2011-11-28

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

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