【问题标题】:wsgi.py' cannot be loaded as Python module - Python3wsgi.py' 不能作为 Python 模块加载 - Python3
【发布时间】:2018-01-16 19:16:11
【问题描述】:

我正在使用 python3 来构建应用程序

[Tue Jan 16 19:07:13.587669 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145] mod_wsgi (pid=22631): Target WSGI script '/u0/shsathya/html/captool/captool/wsgi.py' cannot be loaded as Python module.
[Tue Jan 16 19:07:13.587752 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145] mod_wsgi (pid=22631): Exception occurred processing WSGI script '/u0/shsathya/html/captool/captool/wsgi.py'.
[Tue Jan 16 19:07:13.587979 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145] Traceback (most recent call last):
[Tue Jan 16 19:07:13.588026 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145]   File "/u0/shsathya/html/captool/captool/wsgi.py", line 14, in <module>
[Tue Jan 16 19:07:13.588036 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145]     from django.core.wsgi import get_wsgi_application
[Tue Jan 16 19:07:13.588059 2018] [wsgi:error] [pid 22631:tid 140432910448384] [remote 172.19.217.162:48145] ImportError: No module named 'django.core'

【问题讨论】:

  • 你没有安装 django。
  • 我已经使用 pip3 实用程序安装了 django,并且我能够使用 django-admin 工具并能够运行独立的 django 项目
  • 您的网络服务器设置为使用哪个版本的 Python?我怀疑它是 Python 2,而不是 Python 3。
  • 如何检查我的 apache2 使用的 python 版本?以及如何将其更改为 python3?
  • 要查看您使用的 Python 版本,请创建一个简单的 Python Web 应用程序,该应用程序只打印 sys.version 的值。

标签: python django apache2 wsgi


【解决方案1】:

请确保 django 在 PYTHONPATH 中。 从 python shell 测试 import django

Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
>>>import django
>>>

您需要设置已针对您使用的 python 3 版本编译的 mod_wsgi。 请参考此处验证您的 mod_wsgi 编译为哪个版本的 python-> http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html

【讨论】:

  • 这是我的 ldd 信息 mod_wsgi.py ldd /usr/lib/apache2/modules/mod_wsgi.so linux-vdso.so.1 => (0x00007ffd747c1000) libpython3.5m.so.1.0 = > /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0 (0x00007ff2a8227000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff2a800a000) libc.so。 6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff2a7c40000) libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007ff2a7a17000)
猜你喜欢
  • 1970-01-01
  • 2018-04-01
  • 1970-01-01
  • 2017-08-18
  • 1970-01-01
  • 2020-10-31
  • 2016-10-25
  • 2017-10-13
  • 1970-01-01
相关资源
最近更新 更多