Read the statement by Michael Teeuw here.
PM2 auto start and python virtual environment not playing together
-
Hi, I use Tom Hirschberger’s MMM-Temperature to display temp and humidity from an adafruit sht31d. It has a dependency of the Adafruit CircuitPython Library. I’ve upgrade my pi to Bookworm. Python now runs in a virtual environment. I can activate the virtual environment and get everything to work if I launch MM2 in the virtual environment using npm start. It doesn’t work using PM2 start MagicMirror.
I know you call call python without explicitly activating the environment but I’m not sure what changes need to be made to module.
Maybe create a systemd unit file to run the the library at startup?
Ideally, I want the same functionality back; my MM starts on boot and python works normally.
Has anyone seen this or has a fix?Thanks!
-
@Brown19 in the script launched by pm2, connect to the virtual environment with the venv command , before launching mm
if you setup MagicMirror from my script, then the bash script used is
~/MagicMirror/installers/mm.sh -
-
-
@Brown19 from an educational perspective
the command pm2 info MagicMirror
would have shown you what program. or script was being launchedand then, when you open a terminal window, the .profile and .bashrc scripts are run to setup the user environment.
the .bashrc has the venv command in itwhen pm2 launches a pgm at startup, it is not using a terminal window, so those script are NOT run
you can also use the source command to load them at any timeso you could have done
source .bashrc
instead of
venv…