[Tutor] sys.path.append issues with cgi

Gabriel Farrell gsf at panix.com
Mon Apr 18 19:14:59 CEST 2005


A follow-up to this post for future reference:

It appears that on my web host the cgi scripts run on a web server
that doesn't have access to the same python and python libs that are
available when I ssh in to my shell account.  So it doesn't matter if
I change the sys.path, because the libs are simply not accessible.
This situation is particular to my web hosting service, so it may not
apply to others who are running python cgi scripts and importing
modules.

gabe


On Thu, Apr 14, 2005 at 06:43:26PM -0400, Gabriel Farrell wrote:
> Hello all,
> 
> I'm trying to modify the sys.path in my cgi scripts to import modules
> that I've installed in my home directory.  The top of the script reads
> as follows:
> 
> 
> #!/usr/local/bin/python
> 
> import cgi, sys
> sys.path.append('/net/u/16/g/gsf/lib/python2.4/site-packages')
> from ElementTree import Element, SubElement, tostring
> 
> 
> But my traceback reads:
> 
> ImportError: No module named ElementTree
> 
> 
> The appended path is the same I've added to my PYTHONPATH variable and
> it works fine from the python interactive prompt.  I thought it might
> be a permissions issue since it's a cgi script so I chmodded
> everything up to the ElementTree directory 755 but still no luck.
> 
> TIA,
> gabe
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list