开发者

Make Python 2.6 see Django

开发者 https://www.devze.com 2022-12-25 01:36 出处:网络
In a harrowing attempt to get mod_wsgi to run on CentOS 5.4, I\'ve added Python 2.6 as an option开发者_StackOverflowal library following the instructions here. The configuration seems fine except that

In a harrowing attempt to get mod_wsgi to run on CentOS 5.4, I've added Python 2.6 as an option开发者_StackOverflowal library following the instructions here. The configuration seems fine except that when trying to ping the server the Apache log prints this error:

mod_wsgi (pid=20033, process='otalo', application='127.0.0.1|'): Loading WSGI script '...django.wsgi'. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Target WSGI script '...django.wsgi' cannot be loaded as Python module. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Exception occurred processing WSGI script '...django.wsgi'. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] Traceback (most recent call last): 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218]   File "...django.wsgi", line 8, in <module> 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218]     import django.core.handlers.wsgi 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] ImportError: No module named django.core.handlers.wsgi

when I go to my python2.6 install's command line and try 'import Django', the module is not found (ImportError). However, my default Python 2.4 installation (still working fine) is able to import successfully. How do I point Python 2.6 to Django?


You need to install Django specifically with/for the Python version that's meant to use it -- installs for 2.4 and 2.6 are always going to be separate (they have to be -- there are incompatibilities in binary and bytecode formats!). I don't know what, if any, possibilities CentOS offers for that -- I'd get Django's sources and install from sources (which boils down to: download, tar, cd, and finally a simple sudo python2.6 setup.py install -- or however else you run your 2.6 install of Python). Being a much better developer than I'm a system administrator, I always have a bias in favor of installing from sources for stuff that's really at the core of what I'm doing (especially Python versions and extensions).


I created a write up link text of my experiences of getting Django working on Redhat and and CentOS. I upgraded the version of python that I was using and started with init.d scripts.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号