我正在尝试使用 django-websocket-redis pip 包在 Raspberry Pi 2 上使用 WebSockets 创建 Django 应用程序。 /manage.py runserver 似乎无法正常工作(调用 /ws/ 时出现 404,尽管它是由 WEBSOCKET_URL = '/ws/' 设置的在 settings.py) 中,我想尝试一个独立的 uWSGI 服务器,比如 described here in the official docs .
当我运行 uwsgi 时,出现了奇怪的错误。我认为这是由错误的 python 版本引起的。 uwsgi 的输出告诉我使用的是 Python 2.7:
Python version: 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170124]
但我的项目需要 Python 3(正好是 3.5)。我更改了默认的 python 环境,以便 python comamnd 指向 python 3.5 而不是 2.7。此外,我使用 --plugin 开关传递了版本,如下所示:
uwsgi --http :9090 --plugin=python35 --wsgi-file wsgi.py
我还对所有 pip 包使用了 pip3 以确保没有使用 2.x 包。这似乎没有效果,导致我的脚本中断,uwsgi 告诉我使用的是 Python 2.7...
请您参考如下方法:
安装这个:
sudo apt-get install uwsgi-plugin-python3
