My server system is Debian. I use pm2 to manage the process.
One of the processes is a python backend.
I have created a venv environment for it and activated it. I use this command to change ownership of the directory.
sudo chown myuser /var/www/mybackendcode.
This is my command to start my pm2 process
pm2 start /var/www/mybackendcode/serve.py --interpreter "/var/www/mybackendcode/venv/bin/python3.8" --name HD-backend
It seems that the pm2 process can start successfully, but when I check the status again. The process showed errored.
I check the pm2 log of this process.
Traceback (most recent call last):
26|HD-back | File "/var/www/home_delicious/home_delicious_backend/serve.py", line 1, in <module>
26|HD-back | import bjoern
26|HD-back | ModuleNotFoundError: No module named 'bjoern'
This error message also appears when I run “python3.8 serve.py” to start the server directly.
But when I use "sudo python3.8 serve.py”. the server can be started successfully.
What is the problem? and How can I fix it? Thanks very much!