Running a python 2.5 cgi

software development

#1

Hi,

I followed the instructions on the wiki for setting up my environment and python 2.5, and now if I login and run ‘python’ I get my 2.5 version. If I invoke python in a cgi however, I don’t get the correct python - it seems as though the cgis don’t read ~/.bashrc and don’t see the extra path definitions.

Right now I resolved to put the absolute path for python in the header, but I would prefer not to. help?

Thanks in advance,
Shwouchk.


#2

All of your Python scripts should start with the shebang line of

#!/usr/bin/python2.5

or whichever version you’re using. If you also set your .bash_profile to export your paths correctly then you shouldn’t have any problems either.

  • Greg
  • DreamHost Technical Support

#3

Thanks for your reply - however, it doesn’t work. Here is my .bashrc:

~/.bashrc: executed by bash(1) for non-login shells.

export PATH=~/custom/bin:$PATH

function pathmunge () {
if [ -d $1 ] && ! echo /home/shwouchk/custom/bin:/home/shwouchk/bin:/home/shwouchk/custom/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/shwouchk/django/src/django/bin | /bin/egrep -q "(^|:)$1($|:)“
then
if [ “$2” = “after” ]
then
PATH=/home/shwouchk/custom/bin:/home/shwouchk/bin:/home/shwouchk/custom/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/shwouchk/django/src/django/bin:$1
else
PATH=$1:$PATH
fi
fi
}
export RUN=”${HOME}/custom"
pathmunge ${RUN}/bin

export LD_LIBRARY_PATH=${RUN}/lib:${LD_LIBRARY_PATH}
export LD_RUN_PATH=${RUN}/lib:${LD_RUN_PATH}

perl library search path

PERL5LIB=${RUN}/share/perl/5.8:${RUN}/share/perl/5.8.4:${PERL5LIB}
export PERL5LIB=${RUN}/lib/perl/5.8:${RUN}/lib/perl/5.8.4:${PERL5LIB}

(P.S. this pathmunge function makes no sense to me)

and this is my .bash_profile:

~/.bash_profile: executed by bash(1) for login shells.

umask 002
#PS1=’[\h]$ '
PS1="[\w]$ "

enable color support of ls and also add handy aliases

if [ “$TERM” != “dumb” ]; then
eval "dircolors -b"
alias ls=‘ls --color=auto’
#alias rm ‘mv !* ~/TRASH’
#alias dir=‘ls --color=auto --format=vertical’
#alias vdir='ls --color=auto --format=long’
fi

source .bashrc

mmaybe I wasn’t clear enough, but if I execute the scripts from a shell then they do fine. what’s wrong?