uwsgi+anaconda+django启动问题的坑

记录下今天遇到的一个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的环境有关系。开发的路上都是坑。。

你可能感兴趣的:(django,python)