Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Anaconda python with mod_wsgi

I'm trying to set up my Apache server to use Anaconda python instead of the system python when using mod_wsgi.

Here is my Apache config file:

 LoadModule wsgi_module modules/mod_wsgi.so
 WSGIPythonHome /opt/anaconda/bin
 WSGIPythonPath /opt/anaconda/bin:/opt/anaconda/pkgs

As soon as I start the server, my error log is flooded with

ImportError: No module named site
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

mod_wsgi is version 4.4.12 and compiled with the same version of python as my anaconda installation (2.7.10).

What am I doing wrong? How do I set up my Apache config file to run python from the non-default location?

like image 208
Charlotte Avatar asked Mar 03 '26 23:03

Charlotte


1 Answers

It seems like your Python path is set incorrectly. Go into your Anaconda python and type in:

import site
site

The directory of your site module should be displayed. It should be something like: python_path/lib/site.pyc

Change your Apache configuration to:

WSGIPythonPath python_path:python_path/lib/site-packages

where python_path was the thing you found above when importing site.

like image 138
Ringil Avatar answered Mar 05 '26 13:03

Ringil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!