使用 uwsgi 运行烧瓶时出现导入错误

时间:2021-04-21 10:30:47

标签: nginx flask bokeh uwsgi python-venv

我的服务器出现内部服务器错误,我无法自行解决。链接是我迄今为止尝试过的。但没有任何作用。在我添加散景之前,该网站工作正常。我可以得到一些帮助吗?

编辑:我注意到我的 /venv/lib/python3.7/site-packages 缺少一些模块,包括散景。这可能是原因吗?为什么我在虚拟环境中pip3 install bokeh后它不存在?

EDIT2:我取得了一些进展。我的激活脚本有错误的虚拟环境,所以现在我更正了它。当我现在执行 pip freeze 时,我收到错误 Too many symbolic links -- 修复此问题 - 更新了shebang,它指向自身而不是 python

来自 uwsgi 的日志

    pi@rpi$ uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app
    *** Starting uWSGI 2.0.19.1 (32bit) on [Wed Apr 21 12:08:12 2021] ***
    compiled with version: 8.3.0 on 03 April 2021 20:29:49
    os: Linux-5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021
    nodename: rpi
    machine: armv7l
    clock source: unix
    detected number of CPU cores: 4
    current working directory: /home/pi/myproject
    detected binary path: /home/pi/.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 5334
    your memory page size is 4096 bytes
    detected max file descriptor number: 1048576
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 5
    Python version: 2.7.16 (default, Oct 10 2019, 22:02:15)  [GCC 8.3.0]
    *** Python threads support is disabled. You can enable it with --enable-threads ***
    Python main interpreter initialized at 0x132180
    your server socket listen backlog is limited to 100 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 64408 bytes (62 KB) for 1 cores
    *** Operational MODE: single process ***
    Traceback (most recent call last):
      File "./wsgi.py", line 4, in <module>
        app = create_app()
      File "./application/__init__.py", line 49, in create_app
        from .mypage import mypageView
      File "./application/mypage/mypageView.py", line 1, in <module>
        from bokeh.models import BoxSelectTool, LassoSelectTool, BoxAnnotation, Toggle, HoverTool, ColumnDataSource, LinearAxis, Range1d
    ImportError: No module named bokeh.models
    unable to load app 0 (mountpoint='') (callable not found or import error)
    *** no app loaded. going in full dynamic mode ***
    *** uWSGI is running in multiple interpreter mode ***
    spawned uWSGI worker 1 (and the only) (pid: 7081, cores: 1)

来自服务的日志

apr 21 11:54:45 rpi systemd[1]: Started uWSGI instance to serve site.
apr 21 11:54:45 rpi uwsgi[4513]: [uWSGI] getting INI configuration from myproject.ini
apr 21 11:54:45 rpi uwsgi[4513]: *** Starting uWSGI 2.0.19.1 (32bit) on [Wed Apr 21 11:54:45 2021] ***
apr 21 11:54:45 rpi uwsgi[4513]: compiled with version: 8.3.0 on 17 June 2020 09:19:11
apr 21 11:54:45 rpi uwsgi[4513]: os: Linux-5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021
apr 21 11:54:45 rpi uwsgi[4513]: nodename: rpi
apr 21 11:54:45 rpi uwsgi[4513]: machine: armv7l
apr 21 11:54:45 rpi uwsgi[4513]: clock source: unix
apr 21 11:54:45 rpi uwsgi[4513]: pcre jit disabled
apr 21 11:54:45 rpi uwsgi[4513]: detected number of CPU cores: 4
apr 21 11:54:45 rpi uwsgi[4513]: current working directory: /home/pi/myproject
apr 21 11:54:45 rpi uwsgi[4513]: detected binary path: /home/pi/myproject/venv/bin/uwsgi
apr 21 11:54:45 rpi uwsgi[4513]: your processes number limit is 5334
apr 21 11:54:45 rpi uwsgi[4513]: your memory page size is 4096 bytes
apr 21 11:54:45 rpi uwsgi[4513]: detected max file descriptor number: 1024
apr 21 11:54:45 rpi uwsgi[4513]: lock engine: pthread robust mutexes
apr 21 11:54:45 rpi uwsgi[4513]: thunder lock: disabled (you can enable it with --thunder-lock)
apr 21 11:54:45 rpi uwsgi[4513]: uwsgi socket 0 bound to UNIX address myproject.sock fd 3
apr 21 11:54:45 rpi uwsgi[4513]: Python version: 3.7.3 (default, Jan 22 2021, 20:04:44)  [GCC 8.3.0]
apr 21 11:54:45 rpi uwsgi[4513]: PEP 405 virtualenv detected: /home/pi/myproject/venv
apr 21 11:54:45 rpi uwsgi[4513]: Set PythonHome to /home/pi/myproject/venv
apr 21 11:54:45 rpi uwsgi[4513]: *** Python threads support is disabled. You can enable it with --enable-threads ***
apr 21 11:54:45 rpi uwsgi[4513]: Python main interpreter initialized at 0x2db650
apr 21 11:54:45 rpi uwsgi[4513]: your server socket listen backlog is limited to 100 connections
apr 21 11:54:45 rpi uwsgi[4513]: your mercy for graceful operations on workers is 60 seconds
apr 21 11:54:45 rpi uwsgi[4513]: mapped 386448 bytes (377 KB) for 5 cores
apr 21 11:54:45 rpi uwsgi[4513]: *** Operational MODE: preforking ***
apr 21 11:54:45 rpi uwsgi[4513]: added /home/pi/myproject/venv/ to pythonpath.
apr 21 11:54:47 rpi uwsgi[4513]: Traceback (most recent call last):
apr 21 11:54:47 rpi uwsgi[4513]:   File "./wsgi.py", line 4, in <module>
apr 21 11:54:47 rpi uwsgi[4513]:     app = create_app()
apr 21 11:54:47 rpi uwsgi[4513]:   File "./application/__init__.py", line 49, in create_app
apr 21 11:54:47 rpi uwsgi[4513]:     from .mypage import mypageView
apr 21 11:54:47 rpi uwsgi[4513]:   File "./application/mypage/mypageView.py", line 1, in <module>
apr 21 11:54:47 rpi uwsgi[4513]:     from bokeh.models import BoxSelectTool, LassoSelectTool, BoxAnnotation, Toggle, HoverTool, ColumnDataSource, LinearAxis, Range1d
apr 21 11:54:47 rpi uwsgi[4513]: ModuleNotFoundError: No module named 'bokeh'
apr 21 11:54:47 rpi uwsgi[4513]: unable to load app 0 (mountpoint='') (callable not found or import error)
apr 21 11:54:47 rpi uwsgi[4513]: *** no app loaded. going in full dynamic mode ***
apr 21 11:54:47 rpi uwsgi[4513]: *** uWSGI is running in multiple interpreter mode ***
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI master process (pid: 4513)
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI worker 1 (pid: 4530, cores: 1)
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI worker 2 (pid: 4531, cores: 1)
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI worker 3 (pid: 4532, cores: 1)
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI worker 4 (pid: 4533, cores: 1)
apr 21 11:54:47 rpi uwsgi[4513]: spawned uWSGI worker 5 (pid: 4534, cores: 1)
apr 21 12:00:01 rpi uwsgi[4513]: SIGINT/SIGQUIT received...killing workers...
apr 21 12:00:01 rpi systemd[1]: Stopping uWSGI instance to serve site...
apr 21 12:00:02 rpi uwsgi[4513]: worker 1 buried after 1 seconds
apr 21 12:00:02 rpi uwsgi[4513]: worker 2 buried after 1 seconds
apr 21 12:00:02 rpi uwsgi[4513]: worker 3 buried after 1 seconds
apr 21 12:00:02 rpi uwsgi[4513]: worker 4 buried after 1 seconds
apr 21 12:00:02 rpi uwsgi[4513]: worker 5 buried after 1 seconds
apr 21 12:00:02 rpi uwsgi[4513]: goodbye to uWSGI.
apr 21 12:00:02 rpi uwsgi[4513]: VACUUM: unix socket myproject.sock removed.
apr 21 12:00:02 rpi systemd[1]: myproject.service: Succeeded.
apr 21 12:00:02 rpi systemd[1]: Stopped uWSGI instance to serve site.
apr 21 12:00:02 rpi systemd[1]: Started uWSGI instance to serve site.
apr 21 12:00:02 rpi uwsgi[5547]: [uWSGI] getting INI configuration from myproject.ini
apr 21 12:00:02 rpi uwsgi[5547]: *** Starting uWSGI 2.0.19.1 (32bit) on [Wed Apr 21 12:00:02 2021] ***
apr 21 12:00:02 rpi uwsgi[5547]: compiled with version: 8.3.0 on 17 June 2020 09:19:11
apr 21 12:00:02 rpi uwsgi[5547]: os: Linux-5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021
apr 21 12:00:02 rpi uwsgi[5547]: nodename: rpi
apr 21 12:00:02 rpi uwsgi[5547]: machine: armv7l
apr 21 12:00:02 rpi uwsgi[5547]: clock source: unix
apr 21 12:00:02 rpi uwsgi[5547]: pcre jit disabled
apr 21 12:00:02 rpi uwsgi[5547]: detected number of CPU cores: 4
apr 21 12:00:02 rpi uwsgi[5547]: current working directory: /home/pi/myproject
apr 21 12:00:02 rpi uwsgi[5547]: detected binary path: /home/pi/myproject/venv/bin/uwsgi
apr 21 12:00:02 rpi uwsgi[5547]: your processes number limit is 5334
apr 21 12:00:02 rpi uwsgi[5547]: your memory page size is 4096 bytes
apr 21 12:00:02 rpi uwsgi[5547]: detected max file descriptor number: 1024
apr 21 12:00:02 rpi uwsgi[5547]: lock engine: pthread robust mutexes
apr 21 12:00:02 rpi uwsgi[5547]: thunder lock: disabled (you can enable it with --thunder-lock)
apr 21 12:00:02 rpi uwsgi[5547]: uwsgi socket 0 bound to UNIX address myproject.sock fd 3
apr 21 12:06:37 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:37 rpi uwsgi[6733]: [pid: 6750|app: -1|req: -1/9] 192.168.50.36 () {40 vars in 893 bytes} [Wed Apr 21 12:06:37 2021] GET /%7B%7B%20url_for('static',%20filename='img/50x.gif')%20%7D%7D => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:37 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:37 rpi uwsgi[6733]: [pid: 6750|app: -1|req: -1/10] 192.168.50.36 () {44 vars in 860 bytes} [Wed Apr 21 12:06:37 2021] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:38 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:38 rpi uwsgi[6733]: [pid: 6752|app: -1|req: -1/11] 192.168.50.36 () {44 vars in 930 bytes} [Wed Apr 21 12:06:38 2021] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:38 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:38 rpi uwsgi[6733]: [pid: 6752|app: -1|req: -1/12] 192.168.50.36 () {40 vars in 755 bytes} [Wed Apr 21 12:06:38 2021] GET /main.css => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:38 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:38 rpi uwsgi[6733]: [pid: 6752|app: -1|req: -1/13] 192.168.50.36 () {40 vars in 738 bytes} [Wed Apr 21 12:06:38 2021] GET /main.js => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:38 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:38 rpi uwsgi[6733]: [pid: 6752|app: -1|req: -1/14] 192.168.50.36 () {40 vars in 893 bytes} [Wed Apr 21 12:06:38 2021] GET /%7B%7B%20url_for('static',%20filename='img/50x.gif')%20%7D%7D => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
apr 21 12:06:38 rpi uwsgi[6733]: --- no python application found, check your startup logs for errors ---
apr 21 12:06:38 rpi uwsgi[6733]: [pid: 6750|app: -1|req: -1/15] 192.168.50.36 () {44 vars in 860 bytes} [Wed Apr 21 12:06:38 2021] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

0 个答案:

没有答案