Search code examples
pythonbrowserfeedparserimport

'import feedparser' works via SSH, but fails when in browser


I installed feedparser via SSH, using

$ python setup.py install --home=~/httpdocs/python-libraries/feedparser-4.1/

I did that because I don't seem to have permission to properly run 'python setup.py install'

I am running the following python code in 'test.py'.

print "Content-type: text/html\n\n"
try:
    import feedparser
except:
    print "Cannot import feedparser.\n"

The code runs fine when I am logged in by SSH. But when I view it in a browser, it prints

Cannot import feedparser.

Any ideas?


Solution

  • I tried both the sys.path and the $PYTHONPATH solutions, but they didn't seem to work. I didn't try adding PythonPath to httpd.conf or python.conf - that could have worked.

    I ended up asking a root user to run # python setup.py install for me. That worked.

    I was using Python 2.3.