[Tutor] Shared web host and setting the python environment...

Modulok modulok at gmail.com
Sat Mar 5 06:49:43 CET 2011


I'm on a linux based shared web host. They cater to PHP, not python.
(There's no third party python modules even installed!) So I installed
a virtual python in my home directory, plus easy_install and a bunch
of modules. Great!

The Problem:
Unfortunately, the web server uses the system python, not my virtual
python, or my modules. (It does execute my scripts as my uid though.)
I need modify the environment of every one of my python scripts,
perhaps appending to sys.path, so that my third party modules in my
home directory can be found. I have zero control over the web server
process or its environment.

Possible Solutions I thought of:
One way to do this would be to edit 'sys.path' at the top of every
python script. (Sounds ugly.) Another would be to import the 'user'
module and go that route. (Fine, but it's depricated. What replaces
it?) A third idea would be to re-direct all requests via mod_rewrite
to a single python file or shell script, which sets the environment
and calls my python scripts as a sub-process. (Slow, which is fine,
but some security concerns here.)

Given my situation, what's the best way to accomplish this? (Aside
from a new hosting company or a virtual private server.)

Any suggestions appreciated. Thanks!

More information about the Tutor mailing list