error_log中
...
[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
libpython2.5.so.1.0 => /root/epd-5.1.0/lib/libpython2.5.so.1.0 (0x00002b0829205000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003da0600000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003d9fe00000)
libutil.so.1 => /lib64/libutil.so.1 (0x0000003dadc00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003da0200000)
libc.so.6 => /lib64/libc.so.6 (0x0000003d9fa00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003d9f600000)
有谁知道如何解决这个错误?这是我尝试在redhat系统中运行python脚本或django.wsgi脚本时遇到的唯一错误,之后我将在大学服务器上传我的web应用程序...而且我已经配置VirtualHost。这是唯一的问题,有人可以帮忙吗?谢谢。
答案 0 :(得分:2)
我找到了解决该问题的方法(在redhat系统中),这是一个与Django框架相关的解决方案..
我已经安装了Python 2.6(因此我不再使用默认安装的python),并使用新版本的Python以及其他一些需要的模块重新安装Django:( easy_isntall , MySQL_python-1.2.3-py2.6-linux-x86_64 , setuptools , mod_wsgi-2.5 )所以安装完毕后所有这些模块都要比较在Python 2.6的site-packages目录中:“ /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
配置mod_wsgi以链接Python 2.6共享库
[root@lts5srv1 /]# cd /usr/local/lib/python2.6/config/
[root@lts5srv1 config]# ln -s ../../libpython2.6.so .
[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
然后设置环境变量:
[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
编辑〜/ .bashrc 并添加一些行以保持更改的永久性:
[root@lts5srv1 ~]# vi ~/.bashrc
# .bashrc
# User specific aliases and functions
PATH=/root/epd-5.1.0/lib/python2.5:/root/epd-5.1.0/bin:${PATH}
PYTHONPATH=/usr/local/lib/python2.6
LD_LIBRARY_PATH=/usr/local/lib/python2.6
LD_RUN_PATH=/usr/lib64/httpd/modules
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Django安装:
[root@lts5srv1 Django-1.4.1]# /usr/local/bin/python2.6 setup.py install
然后,检查模块是否正确集成:
[root@lts5srv1 /]# ldd /usr/lib64/httpd/modules/mod_wsgi.so
[root@lts5srv1 /]# ldd /usr/local/bin/python2.6