Python: ImportError: No module named os



[Fri Sep 07 16:30:14 2012] [error] import os
[Fri Sep 07 16:30:14 2012] [error] ImportError: No module named os


[root@lts5srv1 home]# ldd /root/epd-5.1.0/bin/python => /root/epd-5.1.0/lib/ (0x00002b0829205000) => /lib64/ (0x0000003da0600000) => /lib64/ (0x0000003d9fe00000) => /lib64/ (0x0000003dadc00000) => /lib64/ (0x0000003da0200000) => /lib64/ (0x0000003d9fa00000)
    /lib64/ (0x0000003d9f600000)

Anybody know how to solve this error? it's the only error that i get when i try to run a python script or a django.wsgi script in a redhat system, after that i'm going to upload my web-app in a university server... and i've already configuret the VirtualHost. So that was the only problem, can anybody help please? Thank You.

9/7/2012 2:31:04 PM

Accepted Answer

I found a solution for that problem (in redhat system), this is a solution in relation with Django framework..

I've installed Python 2.6 (so i don't use anymore the default installed python), and reinstalled Django using the new version of Python and some other modules that were required like: (easy_isntall, MySQL_python-1.2.3-py2.6-linux-x86_64, setuptools, mod_wsgi-2.5) so after install all these modules should compare in the site-packages directory of Python 2.6: "/usr/local/lib/python2.6/site-packages".

[root@lts5srv1 Python-2.6.8]# ./configure --enable-shared --prefix=/usr/local
[root@lts5srv1 Python-2.6.8]# make
[root@lts5srv1 Python-2.6.8]# make install

Configure mod_wsgi to link with Python 2.6 shared libs

[root@lts5srv1 /]# cd /usr/local/lib/python2.6/config/
[root@lts5srv1 config]# ln -s ../../ .

[root@lts5srv1 mod_wsgi-2.5]# ./configure --with-python=/usr/local/bin/python2.6
[root@lts5srv1 mod_wsgi-2.5]# make 
[root@lts5srv1 mod_wsgi-2.5]# make install

Then setting the environment variables:

[root@lts5srv1 Python-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib/python2.6
[root@lts5srv1 Python-2.6.8]# export LD_RUN_PATH=/usr/lib64/httpd/modules

Editing ~/.bashrc and adding some lines to keep the changes permanent:

[root@lts5srv1 ~]# vi ~/.bashrc

# .bashrc

# User specific aliases and functions


alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc

Django Install:

[root@lts5srv1 Django-1.4.1]# /usr/local/bin/python2.6 install

Then, checking if the modules are correctly integrated:

[root@lts5srv1 /]# ldd /usr/lib64/httpd/modules/
[root@lts5srv1 /]# ldd /usr/local/bin/python2.6
9/11/2012 9:50:58 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow