Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Here's a summary of what I've done

  • I moved my django project to /pymodules/honstreams
  • I've installed apache2 and apache2-dev
  • I've installed pythonbrew, installed Python-2.7.2 and switched to it
  • I've set PYTHONPATH to /pymodules in /etc/profile and confirmed that it works
  • I've compiled mod-wsgi.so using the correct python and apache versions
  • I've added the wsgi module to httpd.conf
  • I've created a wsgi_handler.py instructed by this tutorial. This is it:

    import sys
    import os
    
    sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'honstreams.settings'
    
    import django.core.handlers.wsgi
    
    application = django.core.handlers.wsgi.WSGIHandler()
    
  • I've configured apache VirtualHost instructed by the same tutorial. I edited /etc/apache2/sites-enabled/000-default to this:

    <VirtualHost *>
    
            ServerName www.honstreams.com
            ServerAlias *honstreams.com
    
            Alias /admin_media /root/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/django/contrib/ad$
    
            <Location /admin_media>
                    Order allow,deny
                    Allow from all
            </Location>
    
            Alias /media /root/honstreams/website/media
    
            <Location /media>
                    Order allow,deny
                    Allow from all
            </Location>
    
            WSGIScriptAlias / /root/honstreams/wsgi_handler.py
    
            WSGIDaemonProcess honstreams user=www-data group=www-data processes=1 threads=10
            WSGIProcessGroup honstreams
    
    </VirtualHost>
    

I start apache without errors. I try to access the root folder from http, and /var/log/apache2/error.log repeats:

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

To be perfectly honest I haven't got a clue what to do next. I don't know what <prefix> or <exec_prefix> is and Google isn't being particularly helpful. I'm guessing I need to set the PYTHONHOME variable for user www-data.

Also I'm not trying to import a module named "site" in any of my code, anywhere, ever. Therefore I assume it'll fix itself if I fix the above errors.

Any help would be appreciated!


EDIT: I've set PYTHONHOME to /root/.pythonbrew/pythons/Python-2.7.2 in /etc/profile. I'm getting the exact same error as before. Does /etc/profile even have any effect when a user isn't being logged in at a shell?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I knew all along that my permissions were correct in my Python installation. What I did not know is that if a folder higher up in the hierarchy had more restricting permissions, that would make an impact.

The solution was to ensure that the entire chain of directories from root down to my python installation had rx permissions.

share|improve this answer

As a first shot, I would follow Graham's advice here: http://stackoverflow.com/questions/6946413/interesting-problem-with-python-2-7-on-centos-is-this-an-issue-with-my-build/6948092#6948092. since you are using pythonbrew, to build with options use --configure="--enable-shared --whatever-other-options-you-need-go-here". you may or may not need to symlink around your libraries a bit and explicitly add an LD_LIBRARY_PATH to your .bashrc. hth!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.