Hi, I would go for appending sys.path. This is a simple way to do it, and perhaps not even needed for each python file (only files which use the modules that you have installed))
Another way to do it is adding the modules you need to sys.modules manually. 2011/3/5 Modulok <modu...@gmail.com> > List, > > Background: > 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! > -Modulok- > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor