[mod_python] Importing modules in a new process.

Clodoaldo clodoaldo.pinto.neto at gmail.com
Tue Apr 8 16:41:22 EDT 2008

2008/4/8, Joseph Bernhardt <joe at incomps.com>:
> >
>  > What happens if you run this?:
>  >
>  > import sys
>  > path='/path/to/my/modules'
>  >
>  > if path not in sys.path:
>  >     sys.path.append(path)
>  >
>  > import my_module
>  > import datetime
>  > import sys
>  >
>  > print "Hello World."
>  >
>  > Regards, Clodoaldo
> Thank you Clodoaldo!  This comment allowed me to figure out the primary source of my problem.  When starting a new python process via Popen, it is not only using an older version of python installed on the server, but is also using the module paths associated with that version!  I realize that this is no longer a mod_python problem, but I have been unable to post to the python-list or python-help forums through python.org (don't know why, but it keeps being returned as though my address has been blocked), so I was hoping you could tell me how to change the default python version on RHEL 2.6.9?  I have been searching all over and can't find how it is to be done!

The first thing that comes to my mind is to point the simlink
/usr/bin/python to the version you want. That could break everything
that depends on the old version.

Much safer is to make your script executable and put this line at the top of it:


Regards, Clodoaldo

More information about the Mod_python mailing list