简体   繁体   English

Python + WAMP + Django --> 导入错误:没有名为 os 的模块

[英]Python + WAMP + Django --> ImportError: No module named os

I've installed WAMPServer (latest).我已经安装了 WAMPServer(最新)。 Python 2.6 and Django 1.4. Python 2.6 和 Django 1.4。

Everything looks to be good up until I start running my server.在我开始运行我的服务器之前,一切看起来都很好。 I get Internal Server Error.我收到内部服务器错误。 Apache error log shows the following: Apache错误日志显示如下:

[Sun Apr 08 16:11:27 2012] [error] [client ::1] mod_wsgi (pid=1040): Target WSGI script 'C:/wamp/www/testproject/django.wsgi' cannot be loaded as Python module.
[Sun Apr 08 16:11:27 2012] [error] [client ::1] mod_wsgi (pid=1040): Exception occurred processing WSGI script 'C:/wamp/www/testproject/django.wsgi'.
[Sun Apr 08 16:11:27 2012] [error] Traceback (most recent call last):
[Sun Apr 08 16:11:27 2012] [error]   File "C:/wamp/www/testproject/django.wsgi", line 1, in <module>
[Sun Apr 08 16:11:27 2012] [error]     import os, sys  
[Sun Apr 08 16:11:27 2012] [error] ImportError: No module named os

I've got all my Environment variables and such set up.我已经设置了所有环境变量和此类设置。 Using the Django provided server, it all works.使用 Django 提供的服务器,一切正常。 I want to use Apache.我想使用 Apache。

Your help is greatly appreciated.非常感谢您的帮助。

This can occur when your Python/mod_wsgi installation has been done wrong.当您的 Python/mod_wsgi 安装错误时,可能会发生这种情况。 Key things to check are:要检查的关键事项是:

  1. That Python was installed for all users.为所有用户安装了 Python。
  2. That Python, Apache and mod_wsgi are all 32 bit or all 64 bit.那个Python、Apache和mod_wsgi都是32位的或者都是64位的。 You cannot mix 32 bit and 64 bit.您不能混合使用 32 位和 64 位。
  3. That mod_wsgi was compiled for the version of Python you are using.该 mod_wsgi 是为您正在使用的 Python 版本编译的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM