我正在尝试使用uwsgi运行一些Django代码。当我在正确的virtualenv,它运行正常。但除此之外,当我按如下方式运行时:
uwsgi /home/axial/axial/config.ini
我收到此错误:
2*N
我的config.ini如下:
[uWSGI] getting INI configuration from config.ini
*** Starting uWSGI 2.0.15 (64bit) on [Fri Jul 7 23:34:01 2017] ***
compiled with version: 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564) on 29 June 2017 06:51:11
os: FreeBSD-11.1-RC1 FreeBSD 11.1-RC1 #0 r320486: Fri Jun 30 02:25:16 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC
nodename: axial
machine: amd64
clock source: unix
detected number of CPU cores: 1
current working directory: /usr/home/axial/axial
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 5734
your memory page size is 4096 bytes
detected max file descriptor number: 28467
lock engine: POSIX semaphores
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.13 (default, Jun 29 2017, 01:17:13) [GCC 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)]
Set PythonHome to /home/axial/venv/
ImportError: No module named site
在virtualenv中,没有问题。但是我想在config.ini中指定 virtualenv 会解决这个问题吗?造成这种情况的原因是什么?
这是在FreeBSD上。
旁注:/ home / axial(用户目录),下一个'轴向'是源根目录,下一个'轴?是包含wsgi.py文件的app目录。
答案 0 :(得分:1)
看起来你正在运行Python 2.7
Python version: 2.7.13 (default, Jun 29 2017, 01:17:13) [GCC 4.2.1 Compatible
FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)]
但是你告诉uwsgi寻找Python 3
pythonpath = /home/axial/venv/bin/python3
我不肯定这会解决你所有的问题(因为我也在努力让uwsgi在虚拟环境之外工作),但这是一个开始的地方
您也可以尝试调用虚拟环境的uwsgi二进制文件
/ home / axial / venv / bin / uwsgi --ini /home/axial/axial/config.ini
答案 1 :(得分:0)
目前,FreeBSD上的uwsgi默认为python2。您必须从端口重新编译它。 我在/etc/make.conf中设置了以下内容:
PYTHON_VERSION=python3.6
PYTHON_VERSION_MINIMUM=3.6
DEFAULT_VERSIONS=python=python3.6 python2=2.7 python3=3.6
然后我做了
cd /usr/ports/www/uwsgi && make install clean
它有效!