How can I rebuild my mod_wsgi to use python 2.7.3?

14,376

Solution 1

You have to compile mod_wsgi from source and reinstall.

Most likely as simple as:

$ ./configure
$ make
$ sudo make install

The mod_wsgi documentation covers this in detail.

Solution 2

I didn't have to compile from source, this helped me:

$ apt-get remove libapache2-mod-python libapache2-mod-wsgi 
$ apt-get build-dep libapache2-mod-python libapache2-mod-wsgi 

Solution 3

Remember to check that the files wsgi.load and wsgi.conf are still referenced in the apache2 configuring. For Ubuntu (and probably Debian) that means having a symbolic link from /etc/apache2/mods-available to /etc/apache2/mods-enabled.

Solution 4

Had the same problem, solved by suing virtual environments.

For set up: https://www.digitalocean.com/community/tutorials/how-to-run-django-with-mod_wsgi-and-apache-with-a-virtualenv-python-environment-on-a-debian-vps Just followed the same steps, set up a virtualenv in the same folder as my django app.

Ended up with the following virtual host configuration:

<Directory /storage/sandbox/www/django/sampleapp/static>
    Allow from all
    Order deny,allow
</Directory>
<Directory /storage/sandbox/www/django/sampleapp/media>
    Allow from all
    Order deny,allow
</Directory>
WSGIScriptAlias / /storage/sandbox/www/django/sampleapp/sampleapp/wsgi.py
WSGIPythonPath /storage/sandbox/www/django/sampleapp/:/storage/sandbox/www/django/env/lib/python2.7/site-packages
<Directory /storage/sandbox/www/django/sampleapp/sampleapp>
    <Files wsgi.py>
        Allow from all
        Order deny,allow
    </Files>
</Directory>
Share:
14,376

Related videos on Youtube

babbaggeii
Author by

babbaggeii

Updated on June 04, 2022

Comments

  • babbaggeii
    babbaggeii almost 2 years

    I'm using mod_wsgi to serve up a django website, but I've got an internal server error. Here's the apache log:

    [Fri May 31 10:11:25 2013] [error] python_init: Python version mismatch, expected '2.7.2+', found '2.7.3'.
    [Fri May 31 10:11:25 2013] [error] python_init: Python executable found '/usr/bin/python'.
    [Fri May 31 10:11:25 2013] [error] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload'.
    [Fri May 31 10:11:25 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
    [Fri May 31 10:11:25 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
    [Fri May 31 10:11:25 2013] [notice] Apache/2.2.22 (Ubuntu) DAV/2 mod_fcgid/2.3.6 mod_python/3.3.1 Python/2.7.3 mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 mod_perl/2.0.5 Perl/v5.14.2 configured -- resuming normal operations
    

    So it seems that there's a mismatch between the mod_wsgi version and the runtime version of python. How can I update this?

  • xxinerKYU
    xxinerKYU about 9 years
    This is very obvious but sometimes you just forgot. Thank you!