[ros-users] PYTHONPATH in setup.sh

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: ros-users
Subject: [ros-users] PYTHONPATH in setup.sh
All,
    I believe I must be doing something wrong. In the default install of Cturtle on Ubuntu 10.04, the setup.sh script doesn't jive well with an empty PYTHONPATH environmental variable. Here is my simple debugging test. Note the error on the first run of the python command.


> cmansley@dice:~$ env | grep PYTHONPATH
> cmansley@dice:~$ export ROS_ROOT=/opt/ros/cturtle/ros
> cmansley@dice:~$ export PYTHONPATH=${ROS_ROOT}/core/roslib/src:${PYTHONPATH}
> cmansley@dice:~$ env | grep PYTHONPATH
> PYTHONPATH=/opt/ros/cturtle/ros/core/roslib/src:
> cmansley@dice:~$ python
> 'import site' failed; use -v for traceback
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> Terminated
> cmansley@dice:~$ unset PYTHONPATH
> cmansley@dice:~$ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> Terminated
> cmansley@dice:~$


I believe you need to test if the PYTHONPATH is empty before appending the colon, something like

if [ -n ${PYTHONPATH} ]; then PYTHONPATH=:${PYTHONPATH} fi
export PYTHONPATH=${ROS_ROOT}/core/roslib/src${PYTHONPATH}

-chris