5

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.

NawaMan
  • 25,129
  • 10
  • 51
  • 77

1 Answers1

6

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
  • 442,112
  • 142
  • 972
  • 1,088