在我的烧瓶项目中,我使用uwsgi运行它。
在我的项目中有import psutil。
当然,我在我的静脉里安装了最新的psutil:
(venv) [root@7338cdd80407 ssl-node]# pip3 install --upgrade psutil
Requirement already satisfied: psutil in /www/wwwroot/ssl-node/venv/lib64/python3.6/site-packages (5.8.0)但是当我执行我的烧瓶代码时,会得到错误的ModuleNotFoundError: No module named 'psutil'。
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 703600 bytes (687 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
added /www/wwwroot/ssl-node/ssl-node/ to pythonpath.
Traceback (most recent call last):
File "/www/wwwroot/ssl-node/ssl-node/manager.py", line 9, in <module>
from api import app
File "/www/wwwroot/ssl-node/ssl-node/api.py", line 5, in <module>
from utils import utils, util_check_pem_key_cert
File "/www/wwwroot/ssl-node/ssl-node/utils/utils.py", line 8, in <module>
from .util_process import (
File "/www/wwwroot/ssl-node/ssl-node/utils/util_process.py", line 6, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
unable to load app 0 (mountpoint='') (callable not found or import error)编辑-01
我的pip3和pip都来自venv
(venv) [root@7338cdd80407 ssl-node]# which pip3
/www/wwwroot/ssl-node/venv/bin/pip3
(venv) [root@7338cdd80407 ssl-node]# which pip
/www/wwwroot/ssl-node/venv/bin/pip编辑-02
我的python3路径:
(venv) [root@7338cdd80407 ssl-node]# which python3
/www/wwwroot/ssl-node/venv/bin/python3我使用uwsgi -d --ini uwsgi_prod.ini执行我的烧瓶项目:
uwsgi_prod.ini内容:
[uwsgi]
http=0.0.0.0:5000
processes=4
threads=2
master=true
pythonpath=/www/wwwroot/ssl-node/ssl-node
module=manager
callable=app
memory-report=true
buffer-size=32768
static-map=/static=/www/wwwroot/ssl-node/ssl-node/static
daemonize=/www/wwwroot/ssl-node/ssl-node/log/uwsgi.log您可以看到从manager.py中执行:它的内容:
#-*- coding:utf-8 -*-
# Author: jack
import sys,os
path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(path)
from api import app
if __name__ == "__main__":
app.run("0.0.0.0")https://stackoverflow.com/questions/67938566
复制相似问题