总结uwsgi+anaconda+django启动遇到的问题

news/2024/9/29 12:19:20 标签: django, python, uwsgi, anconda

一、问题描述

Django中,anconda环境下安装uwsgi,启动遇到的问题:

按照正常的启动方式启动:

uwsgi --ini uwsgi_py.ini

但是报错:

Traceback (most recent call last):
  File "/opt/myproject/myproject/wsgi.py", line 12, in <module>
    from django.core.wsgi import get_wsgi_application
  File "/root/anaconda3/envs/xxx/lib/python3.11/site-packages/django/__init__.py", line 1, in <module>
    from django.utils.version import get_version
  File "/root/anaconda3/envs/xxx/lib/python3.11/site-packages/django/utils/version.py", line 1, in <module>
    import datetime
  File "/root/anaconda3/envs/xxx/lib/python3.11/datetime.py", line 12, in <module>
    import math as _math
ImportError: /root/anaconda3/envs/lottery/lib/python3.11/lib-dynload/math.cpython-311-x86_64-linux-gnu.so: undefined symbol: _PyModule_Add
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 43924)
spawned uWSGI worker 1 (pid: 43925, cores: 1)
spawned uWSGI worker 2 (pid: 43926, cores: 1)
spawned uWSGI worker 3 (pid: 43927, cores: 1)
spawned uWSGI http 1 (pid: 43928)
--- no python application found, check your startup logs for errors ---
--- no python application found, check your startup logs for errors ---
--- no python application found, check your startup logs for errors ---
--- no python application found, check your startup logs for errors ---

二、分析原因

uwsgi没有起来

三、解决办法:

不管怎么改配置都报这个错,网上很多解答,但是没有成功的。

这个问题的关键是:在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的环境有关系。

四、附加:

如果还出现问题,估计python版本与uwsgi不兼容,解决办法如下:

1、anconda环境下新建环境:
conda create -n ps39 python=3.9
2、进入指定的环境
conda activate ps39
3、重新运行代码
uwsgi --ini uwsgi_py.ini
4、查看日志,程序运行正常
*** Starting uWSGI 2.0.21 (64bit) on [Wed Sep 25 08:38:32 2024] ***
compiled with version: 11.2.0 on 05 August 2024 19:30:51
os: Linux-5.4.0-196-generic #216-Ubuntu SMP Thu Aug 29 13:26:53 UTC 2024
nodename: python
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 16
current working directory: /root/app/text_detection/script
writing pidfile to /root/app/text_detection/script/pid_uwsgi.pid
detected binary path: /opt/anaconda/install/envs/ps39/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /root/app/text_detection
your processes number limit is 128219
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 172.16.13.157:8010 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.9.19 (main, May  6 2024, 19:43:03)  [GCC 11.2.0]
Python main interpreter initialized at 0xfff4f0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 403077 bytes (393 KB) for 2 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xfff4f0 pid: 868081 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 868081)
spawned uWSGI worker 1 (pid: 868082, cores: 1)
spawned uWSGI worker 2 (pid: 868083, cores: 1)


http://www.niftyadmin.cn/n/5683007.html

相关文章

2024网安周 | 百度安全深度参与,探索人工智能与数字安全的融合发展之路

9月9日-15日&#xff0c;2024年国家网络安全宣传周在全国范围内统一举行&#xff0c;本届网安周继续以“网络安全为人民&#xff0c;网络安全靠人民”为主题&#xff0c;由中央宣传部、中央网信办、教育部、工业和信息化部、公安部、中国人民银行、国家广播电视总局、全国总工会…

【AI变现】探索AI领域的财富密码:5大AI变现路径解析

随着现代科技的高速发展&#xff0c;AI已经不只是一个概念工具&#xff0c;它正在深刻地改变着我们的生活方式、工作模式和商业模式。 在这个AI无处不在的时代&#xff0c;如何抓住机遇&#xff0c;利用AI技术创造财富&#xff0c;成为了许多人关注的焦点。 接下来&#xff0…

QT--基础

将默认提供的程序都注释上意义 0101.pro QT core gui #QT表示要引入的类库 core&#xff1a;核心库 gui&#xff1a;图形化界面库 #如果要使用其他库类中的相关函数&#xff0c;则需要加对应的库类后&#xff0c;才能使用 greaterThan(QT_MAJOR_VERSION, 4): QT wid…

HI3520DV510 22AP80/SS522V100 芯片及开发板

22AP80是针对多路高清/超高清&#xff08;1080P/4M/5M/4K&#xff09;DVR产品应用开发的新一代专业SoC芯片。 22AP80集成了ARM Cortex-A7四核处理器和性能强大的图像分析工具推理引擎&#xff0c;支持多种智能算法应 用。同时&#xff0c;22AP80还集成了多路MIPI D-PHY接口输入…

前端vuex

需要共享的数据适合存储到vuex中 state基本使用 如果开启strict严格模式&#xff0c;直接修改上图的age会报错提示。不能在组件中直接修改state 总结&#xff1a; 分模块使用

网络服务管理

&#x1f4d1;打牌 &#xff1a; da pai ge的个人主页 &#x1f324;️个人专栏 &#xff1a; da pai ge的博客专栏 ☁️宝剑锋从磨砺出&#xff0c;梅花香自苦寒来 # 学习方法&#xff1a; ## 当天…

56 门控循环单元(GRU)_by《李沐:动手学深度学习v2》pytorch版

系列文章目录 文章目录 系列文章目录门控循环单元&#xff08;GRU&#xff09;门控隐状态重置门和更新门候选隐状态隐状态 从零开始实现初始化模型参数定义模型训练与预测 简洁实现小结练习 门控循环单元&#xff08;GRU&#xff09; 之前我们讨论了如何在循环神经网络中计算梯…

C++的STL标准模板库容器--vector类

前言&#xff1a;vector类也可以叫作顺序表&#xff0c;他同样也在STL库中的容器模块中&#xff0c;我还是主要讲常用的几个成员函数和成员变量&#xff0c;同时它晚于string类&#xff0c;所以在设计上没有string冗余。 vector类是一个和数组类似的容器&#xff0c;它属于随机…