Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should WSGIPythonPath point in my virtualenv?

Tags:

I have a folder called python2.7 inside of lib in the virtual environment.

After reading half a dozen tutorials, I can't figure out exactly what I'm suppose to point the WSGIPythonPath to. I've seen some pointing to site-packages but some have been a colon : separated list.

Syntax error on line 1019 of /etc/httpd/conf/httpd.conf: WSGIPythonPath cannot occur within <VirtualHost> section 

Where should WSGIPythonPath point in my virtualenv?

like image 687
user83039 Avatar asked Jan 08 '15 04:01

user83039


People also ask

How do I add a path to Virtualenv?

Just put a file with a . pth extension (any basename works) in your virtualenv's site-packages folder, e.g. lib\python2. 7\site-packages , with the absolute path to the directory containing your package as its only contents.

What is WSGIPythonHome?

WSGIPythonHome prefix|prefix:exec_prefix. Context: server config. Used to indicate to Python when it is initialised where its library files are installed.

What is WSGIDaemonProcess?

The WSGIDaemonProcess directive can be used to specify that distinct daemon processes should be created to which the running of WSGI applications can be delegated.


1 Answers

You are getting the error because WSGIPythonPath Directive cannot be used inside the VirtualHost context. You have to declare it inside your main Apache configuration file. If you still want to point to the directories in your virtualenv inside the VirtualHost context, Use WSGIDaemonProcess Directive instead, it has a python-path option for you to declare your relevant python directories.

For example: your virtual host configuration file should look something like this:

<VirtualHost *:80> ServerName example.com CustomLog logs/example.com-access_log common ErrorLog logs/example.com-error_log  WSGIDaemonProcess example.com python-path=/virtualenvpathto/site-packages:/pathto/exampleprojecthome WSGIProcessGroup example.com  ... </VirtualHost> 

The full colon : is used when you have more than one python directories you want to be added to $PYTHON_PATH environment variable so that say import example.foo works fine. In the above example, there are two directories, they could be more or less depending on how you have setup your project.

If you are on windows, use semicolon ; instead of full colon.

I hope this helps.

like image 177
kaykae Avatar answered Oct 05 '22 02:10

kaykae