python - Apache2&Django - NameError:未定义名称“AttributeError”
问题描述
我几乎按照所有官方文档来让我的 Django 项目在我的 Ubuntu 18.04 v-server 上运行。它似乎工作...... sudo service apache2 status -> 一切都很好。
[Sun May 03 16:07:20.489608 2020] [mpm_event:notice] [pid 11531:tid 139884218760128] AH00489:
Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.7.1 Python/3.8 configured -- resuming normal operations
[Sun May 03 16:07:20.489764 2020] [core:notice] [pid 11531:tid 139884218760128] AH00094:
Command line: '/usr/sbin/apache2'
我首先注意到,如果我的模板在没有服务器重启的情况下不会更新,这不是 Django 的通常行为(即使在生产环境中),某些东西会出现问题。每当我重新启动服务器时,我都会在 apache2/error.log 中收到此错误。尽管服务器继续工作,但我想深入了解这一点。
Exception ignored in: <function Local.__del__ at 0x7fbd983f03a0>
Traceback (most recent call last):
File "/var/www/my_app/.my_app/lib/python3.8/site-packages/asgiref/local.py", line 95, in __del__
NameError: name 'AttributeError' is not defined
Exception ignored in: <function Local.__del__ at 0x7fbd983f03a0>
Traceback (most recent call last):
File "/var/www/my_app/.my_app/lib/python3.8/site-packages/asgiref/local.py", line 95, in __del__
NameError: name 'AttributeError' is not defined
[Sun May 03 16:07:19.418926 2020] [core:warn] [pid 11433:tid 140452536064960] AH00045: child process 11435 still did not exit, sending a SIGTERM
[Sun May 03 16:07:20.419208 2020] [mpm_event:notice] [pid 11433:tid 140452536064960] AH00491: caught SIGTERM, shutting down
[Sun May 03 16:07:20.489608 2020] [mpm_event:notice] [pid 11531:tid 139884218760128] AH00489: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.7.1 Python/3.8 configured -- resuming normal operations
[Sun May 03 16:07:20.489764 2020] [core:notice] [pid 11531:tid 139884218760128] AH00094: Command line: '/usr/sbin/apache2'
- Ubuntu 18.04
- Python3.8.0 并通过 update-alternatives 链接到 python-command
- Python 在 venv 中运行
项目结构:
in /var/www/:
|-- my_app
| |-- my_app
| | |-- __init__.py
| | |-- asgi.py
| | |-- settings.py
| | |-- urls.py
| | `-- wsgi.py
| |-- db.sqlite3
| |-- manage.py
| |-- media
| |-- .my_app (python venv)
| |-- my_subapp
| | |-- __init__.py
| | |-- admin.py
| | |-- apps.py
| | |-- migrations
| | |-- models.py
| | |-- tests.py
| | |-- urls.py
| | `-- views.py
| `-- templates
| |-- base.html
| `-- index.html
有什么建议可能是错误的,为什么它说“找不到属性错误?” 当它似乎是开箱即用的标准python类时...谢谢您的帮助:-)
解决方案
我花了一天的时间才找出问题所在 - 感谢 Graham Dumpleton - mod_wsgi 的创建者解释了一切。你可以在这里查看:
推荐阅读
- vb.net - Visual Studio 中的 Word 文档文件夹路径
- python - 在另一个脚本中调用时,Tkinter 不显示输出
- reactjs - 测试库 - 未调用测试 onChange
- spring - Spring Security 身份验证和用户界面
- javascript - Firebase onAuthStateChange() 状态不会改变
- r - 使用 dply 为每个组创建百分比
- macos - Ecamm Live 等虚拟相机未出现在经过公证的 mac 电子应用程序中
- javascript - 如何根据客户的输入动态查找用户?[解决了]
- c++ - C++:使用元组的 TypeDef
- ios - Flutter Firestore 删除的文档变灰并意外复活