views:

15

answers:

1
+1  Q: 

PYTHONPATH and PHP

I have a PHP script that call a python script (someone else I can't edit). This work fine on CLI but once I run it as CGI it fails with the error "bzr: ERROR: Couldn't import bzrlib and dependencies."

I guessed it has anything to do with PYTHONPATH so I echo it out and found that it was empty when in apache environment.

I try setting it in my '.htaccess' (I am on Dreamhost so I can't set httpd.conf) as:

SetEnv PYTHONPATH "/home/nawaman/lib/python"

It still does not work.

What can I do about this? Thanks in advance for any help.

+1  A: 

As far as I know, Apache's environment variables don't correlate with the system ones.

Try setting PYTHONPATH using PHP's putenv()

Alternatively, I don't know much about Python, but it seems to be possible to set the path inside a Python script using sys.path maybe that helps.

Pekka
`putenv()` works. Such a simple solution that really work. Thank you very very much.
NawaMan