记录下今天遇到的一个uwsgi启动django带来的坑。历经一下午终于找到了问题的原因。
问题
按照正常的启动方式启动:
uwsgi --ini uwsgi_soc.ini
但是报错
*** warning: you are running uwsgi as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145776 bytes (142 kb) for 1 cores
*** operational mode: single process ***
traceback (most recent call last):
file "soc/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
file "/users/zero/opt/anaconda3/lib/python3.7/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
file "/users/zero/opt/anaconda3/lib/python3.7/site-packages/django/utils/version.py", line 1, in <module>
import datetime
file "/users/zero/opt/anaconda3/lib/python3.7/datetime.py", line 8, in <module>
import math as _math
importerror: dlopen(/users/zero/opt/anaconda3/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so, 2): symbol not found: _pyexc_memoryerror
referenced from: /users/zero/opt/anaconda3/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so
expected in: flat namespace
in /users/zero/opt/anaconda3/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
不管怎么改配置都报这个错,网上很多解答,但是没有成功的。
这个问题的关键是
在anaconda 环境下安装uwsgi:
pip install uwsgi
这个不行的,安装成功,但是anaconda环境下使用就会出这个问题。
所以要在anaconda下使用uwsgi,
请按照下面的方式去安装
anaconda search -t conda uwsgi anaconda show conda-forge/uwsgi conda install --channel https://conda.anaconda.org/conda-forge uwsgi
用conda安装uwsgi就可以了。
这个应该和conda的环境有关系。开发的路上都是坑。。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论