unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 691 forks source link

uWSGI can't import any module for a Flask App #2242

Open invictusro opened 4 years ago

invictusro commented 4 years ago

Hello guys so I do have a Flask app and I wanted to run it with uWSGI. The flask app runs fine with python 3.7.3 the same python that runs in my uWSGI too. However, I get import errors when trying the run my flask app. Here is my uwsgi config.ini:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

It worked fine before I have upgraded my pip. Here are the errors:

[uWSGI] getting INI configuration from /home/pi/sampleApp/uwsgi_config.ini
*** Starting uWSGI 2.0.19.1 (32bit) on [Tue Oct 20 23:11:02 2020] ***
compiled with version: 8.3.0 on 17 June 2020 09:19:11
os: Linux-5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020
nodename: raspberrypi
machine: armv7l
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/pi
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
chdir() to /home/pi/sampleApp
your processes number limit is 12873
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 UNIX address /tmp/sample_app.sock fd 3
uwsgi socket 1 bound to TCP address 0.0.0.0:3134 fd 4
Python version: 3.7.3 (default, Jul 25 2020, 13:03:44)  [GCC 8.3.0]
Python main interpreter initialized at 0x1f4a748
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 143968 bytes (140 KB) for 2 cores
*** Operational MODE: threaded ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1648)
spawned uWSGI worker 1 (pid: 1649, cores: 2)
Traceback (most recent call last):
  File "./sample_app.py", line 1, in <module>
    import mysql.connector
ModuleNotFoundError: No module named 'mysql'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
xrmx commented 4 years ago

Are you sure you have mysql module available to the python3.7.3 you are using with uwsgi?

invictusro commented 4 years ago

@xrmx as I said, if I runt it in local machine it works fine. Here is an example: https://prnt.sc/v3ciad