python - 服务器上的 django 应用程序 : apache runs with python 2. 7 而不是 python 3.5

标签 python django apache python-3.x ubuntu

我的 ubuntu 服务器上有一个 Django 应用程序。到目前为止,我使用的是 python 2.7。

我的 Django 版本是 1.11.6。

从现在开始,我想使用 python 3.5。但是当我运行 sudo service apache2 restart我收到包含 python 2.7 的错误:

[Mon Oct 23 12:40:53.500064 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] mod_wsgi (pid=28615): Target WSGI script '/home/zinonas/guardianangel/GuardianAngel/wsgi.py' cannot be loaded as Python module.
[Mon Oct 23 12:40:53.500102 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] mod_wsgi (pid=28615): Exception occurred processing WSGI script '/home/zinonas/guardianangel/GuardianAngel/wsgi.py'.
[Mon Oct 23 12:40:53.500125 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] Traceback (most recent call last):
[Mon Oct 23 12:40:53.500144 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/home/zinonas/guardianangel/GuardianAngel/wsgi.py", line 15, in <module>
[Mon Oct 23 12:40:53.500203 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     application = get_wsgi_application()
[Mon Oct 23 12:40:53.500213 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Mon Oct 23 12:40:53.500240 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     django.setup(set_prefix=False)
[Mon Oct 23 12:40:53.500250 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup
[Mon Oct 23 12:40:53.500281 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Oct 23 12:40:53.500308 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 56, in __getattr__
[Mon Oct 23 12:40:53.500371 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     self._setup(name)
[Mon Oct 23 12:40:53.500381 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
[Mon Oct 23 12:40:53.500393 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     self._wrapped = Settings(settings_module)
[Mon Oct 23 12:40:53.500398 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 110, in __init__
[Mon Oct 23 12:40:53.500406 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Oct 23 12:40:53.500411 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Oct 23 12:40:53.500443 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434]     __import__(name)
[Mon Oct 23 12:40:53.500466 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] ImportError: No module named settings.mysql

你知道如何解决这个问题吗?

最佳答案

也许你安装了用于 python 2 的 libapache2-mod-wsgi 包。

对于 python 3,您需要安装 libapache2-mod-wsgi-py3,然后 apache 将使用 python3。

关于python - 服务器上的 django 应用程序 : apache runs with python 2. 7 而不是 python 3.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46889709/

相关文章:

python - 像常规数据框一样过滤 pandas hub_table 结果

Django CMS 和 Rosetta : Can't get template messages translated

ruby-on-rails - Apache 反向代理 Unix 套接字

linux - Apache 用户无法在 777 目录中创建文件

django - 使用 Django 1.7 中的 AppConfig 就绪方法在 Django 启动时加载静态数据

Apache + mod_lisp + clisp

python - 组合 DataFrame 行以消除 NaN

Python - 在满足条件的特定日期后返回行

python - 将 python 脚本转换为 .exe 时出现 "ImportError: No module named xlsxwriter"

javascript - Django + Jquery + Ajax + D3 不起作用