Ask Your Question
0

Askbot Python2.6 Django VirtualEnv PostgreSQL ImportError : No module named OS

asked 2014-12-19 02:27:03 -0500

danny gravatar image

updated 2014-12-19 03:41:43 -0500

Installed askbot using pip in my Centos 6.5 and having issues while trying to access from browsers. Following is the error message displayed in my Apache error_log while accessing it through browser

[Fri Dec 19 18:16:14 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Dec 19 18:16:14 2014] [notice] Digest: generating secret for digest authentication ...
[Fri Dec 19 18:16:14 2014] [notice] Digest: done
[Fri Dec 19 18:16:14 2014] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations
[Fri Dec 19 18:16:14 2014] [info] mod_wsgi (pid=8088): Attach interpreter ''.
[Fri Dec 19 18:16:32 2014] [info] mod_wsgi (pid=8088): Create interpreter 'communitydev.india.vembu.com.100.168.192.in-addr.arpa|'.
[Fri Dec 19 18:16:32 2014] [info] [client 192.168.100.45] mod_wsgi (pid=8088, process='askbot', application='communitydev.india.vembu.com.100.168.192.in-addr.arpa|'): Loading WSGI script '/home/askbot/askbotdjangosite/django.wsgi'.
[Fri Dec 19 18:16:32 2014] [error] [client 192.168.100.45] mod_wsgi (pid=8088): Target WSGI script '/home/askbot/askbotdjangosite/django.wsgi' cannot be loaded as Python module.
[Fri Dec 19 18:16:32 2014] [error] [client 192.168.100.45] mod_wsgi (pid=8088): Exception occurred processing WSGI script '/home/askbot/askbotdjangosite/django.wsgi'.
[Fri Dec 19 18:16:32 2014] [error] Traceback (most recent call last):
[Fri Dec 19 18:16:32 2014] [error]   File "/home/askbot/askbotdjangosite/django.wsgi", line 1, in <module>
[Fri Dec 19 18:16:32 2014] [error]     import os
[Fri Dec 19 18:16:32 2014] [error] ImportError: No module named os

Following is my wsgi.conf file contents

LoadModule wsgi_module modules/mod_wsgi.so

#the following two directories must be both readable and writable by apache
WSGISocketPrefix /var/run/wsgi
WSGIPythonEggs /var/python/eggs

#the following directory must be readable by apache
WSGIPythonHome /usr/lib64/python2.6

Following is my vhosts.conf file content

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /home/askbot/askbotdjangosite/
    ServerAlias Communitydev

    ErrorLog logs/error_log
    CustomLog logs/access_log combined
        LogLevel debug

     Alias /m/ /home/askbot/askbotdjangosite/static/
     Alias /upfiles/ /home/askbot/askbotdjangosite/askbot/upfiles/
     <DirectoryMatch "/home/askbot/askbotdjangosite/askbot/skins/([^/]+)/media">
        Order deny,allow
        Allow from all
     </DirectoryMatch>
     <Directory "/home/askbot/askbotdjangosite/askbot/upfiles">
        Order deny,allow
        Allow from all
     </Directory>
     #must be a distinct name within your apache configuration
     WSGIDaemonProcess askbot
     WSGIProcessGroup askbot
     WSGIScriptAlias / /home/askbot/askbotdjangosite/django.wsgi
     #make all admin stuff except media go through secure connection
     <LocationMatch "/admin(?!/media)">
                RewriteEngine on
        RewriteRule /admin(.*)$ https : / /Communitydev/admin$1 [L,R=301]
     </LocationMatch>
</VirtualHost>


NameVirtualHost *:443

<VirtualHost *:443>
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

    SSLCertificateFile      /etc/httpd/ssl/apache.crt
    SSLCertificateKeyFile   /etc/httpd/ssl/apache.key

    ServerName      "Communitydev"
    DocumentRoot /home/askbot/askbotdjangosite/

    CustomLog       logs/ssl_access_log combined
    ErrorLog        logs/ssl_error_log

     <LocationMatch "^(?!/admin)">
         RewriteEngine on
         RewriteRule django.wsgi(.*)$ http : / / example.com$1 [L,R ...
(more)
edit retag flag offensive close merge delete

Comments

Just a quick note, this is not an Askbot issue, but something more general regarding the apache configuration and/or your Python installation. Looks like an issue with the pythonpath.

Evgeny gravatar imageEvgeny ( 2014-12-19 02:37:46 -0500 )edit

@Evgeny Yes, I agree that this is not an issue with askbot. Am new to Python environment, any idea how to proceed further in solving this problem.

danny gravatar imagedanny ( 2014-12-19 03:39:13 -0500 )edit

Sorry I don't have the time at the moment. Hopefully either someone else helps or you will find the solution elsewhere. I would recommend instead use nginx + uwsgi, the setup is simpler than with Apache. Please look for a general solution of type "how to deploy a django application.

Evgeny gravatar imageEvgeny ( 2014-12-19 03:44:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-12-22 03:48:13 -0500

danny gravatar image

Solved this problem by correcting the WSGIPythonHome and WSGIPythonPath values in wsgi.conf file. My wsgi.conf file contents as follows,

LoadModule wsgi_module modules/mod_wsgi.so

#the following two directories must be both readable and writable by apache
WSGISocketPrefix /var/run/wsgi
WSGIPythonEggs /var/python/eggs

#the following directory must be readable by apache
WSGIPythonHome /usr
WSGIPythonPath /usr/bin

After this, added the following few lines of code into django.wsgi file exists at /path/to/askbotdjangosite/

import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/path/to/virtual/askbot/lib64/python2.6/site-packages')

# Activate your virtual env
activate_env=os.path.expanduser("/path/to/virtual/askbot/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

And this has resolved my issues.

@Evgeny, Thanks for your comments.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-12-19 02:27:03 -0500

Seen: 2,393 times

Last updated: Dec 22 '14