Hi,<div><br></div><div>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))</div><div><br></div><div>
Another way to do it is adding the modules you need to sys.modules manually.<br><br><div class="gmail_quote">2011/3/5 Modulok <span dir="ltr">&lt;<a href="mailto:modulok@gmail.com">modulok@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
List,<br>
<br>
Background:<br>
I&#39;m on a linux based shared web host. They cater to PHP, not python.<br>
(There&#39;s no third party python modules even installed!) So I installed<br>
a virtual python in my home directory, plus easy_install and a bunch<br>
of modules. Great!<br>
<br>
The Problem:<br>
Unfortunately, the web server uses the system python, not my virtual<br>
python, or my modules. (It does execute my scripts as my uid though.)<br>
I need modify the environment of every one of my python scripts,<br>
perhaps appending to sys.path, so that my third party modules in my<br>
home directory can be found. I have zero control over the web server<br>
process or its environment.<br>
<br>
Possible Solutions I thought of:<br>
One way to do this would be to edit &#39;sys.path&#39; at the top of every<br>
python script. (Sounds ugly.) Another would be to import the &#39;user&#39;<br>
module and go that route. (Fine, but it&#39;s depricated. What replaces<br>
it?) A third idea would be to re-direct all requests via mod_rewrite<br>
to a single python file or shell script, which sets the environment<br>
and calls my python scripts as a sub-process. (Slow, which is fine,<br>
but some security concerns here.)<br>
<br>
Given my situation, what&#39;s the best way to accomplish this? (Aside<br>
from a new hosting company or a virtual private server.)<br>
<br>
Any suggestions appreciated. Thanks!<br>
<font color="#888888">-Modulok-<br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</font></blockquote></div><br></div>