django wsgi 错误找不到名为站点名称的模块
Posted
技术标签:
【中文标题】django wsgi 错误找不到名为站点名称的模块【英文标题】:django wsgi error no module found named site name 【发布时间】:2018-11-14 10:49:56 【问题描述】:当我运行命令uwsgi --http :8081 --gevent 100 --module websocket --gevent-monkey-patch --master -H env/
时出现错误找不到python 应用程序,当我指定wsgi.py
文件的路径时,uwsgi --http :8081 --gevent 100 --模块 websocket --gevent-monkey-patch --master -H env/ --wsgi-file /Users/ishansrivastava/Desktop/ChatApp/Chatire/chatire/wsgi.py`,我明白了
ModuleNotFoundError: No module named 'chatire'
DAMN ! worker 1 (pid: 77847) died :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 77851)
*** running gevent loop engine [addr:0x104312c00] ***
Traceback (most recent call last):
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/gevent/monkey.py", line 611, in patch_all
patch_thread(Event=Event, _warnings=_warnings)
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/gevent/monkey.py", line 348, in patch_thread
_patch_existing_locks(threading_mod)
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/gevent/monkey.py", line 263, in _patch_existing_locks
if isinstance(o, rlock_type):
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/django/utils/functional.py", line 215, in inner
self._setup()
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/ishansrivastava/Desktop/ChatApp/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
当我 cd 进入目录 chatire
并再次运行相同的命令时,我得到
OSError: unable to complete websocket handshake
[pid: 79930|app: 0|req: 1/1] 127.0.0.1 () 46 vars in 789 bytes [Wed Nov 14 16:13:37 2018] GET /475ae83b85db4d0 => generated 0 bytes in 67 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 99)
you need to build uWSGI with SSL support to use the websocket handshake api function !!!
Traceback (most recent call last):
File "./websocket.py", line 30, in application
env.get('HTTP_ORIGIN', '')
OSError: unable to complete websocket handshake
[pid: 79930|app: 0|req: 2/2] 127.0.0.1 () 46 vars in 789 bytes [Wed Nov 14 16:13:46 2018] GET /475ae83b85db4d0 => generated 0 bytes in 19 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 99)
you need to build uWSGI with SSL support to use the websocket handshake api function !!!
Traceback (most recent call last):
File "./websocket.py", line 30, in application
env.get('HTTP_ORIGIN', '')
OSError: unable to complete websocket handshake
[pid: 79930|app: 0|req: 3/3] 127.0.0.1 () 46 vars in 789 bytes [Wed Nov 14 16:13:54 2018] GET /475ae83b85db4d0 => generated 0 bytes in 25 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 99)
^CSIGINT/SIGQUIT received...killing workers...
Brutally killing worker 1 (pid: 79930)...
Wed Nov 14 16:14:00 2018 - stopping gevent signals watchers for worker 1 (pid: 79930)...
gateway "uWSGI http 1" has been buried (pid: 79932)
Wed Nov 14 16:14:00 2018 - stopping gevent sockets watchers for worker 1 (pid: 79930)...
Wed Nov 14 16:14:00 2018 - main gevent watchers stopped for worker 1 (pid: 79930)...
【问题讨论】:
【参考方案1】:在根文件夹中试试这个命令:
uwsgi --http :8081 --gevent 100 --module websocket --gevent-monkey-patch --master
在根文件夹中必须有一个名为websocket.py
的模块。
如果您使用的是 virtualenv,请确保它已激活并安装了所有依赖项。
【讨论】:
以上是关于django wsgi 错误找不到名为站点名称的模块的主要内容,如果未能解决你的问题,请参考以下文章
错误:在 apache 上运行 django 时找不到目标 WSGI 脚本或无法统计
Django Apache 和 Virtualenv ImportError:没有名为站点的模块
使用 apache mod_wsgi 的 Django 多个站点:请求到错误的站点