So the problem was with how I was spawning flaskProc in the main.js file. I was using spawn("py",[path])
, simply thinking that py was used to indicate it was Python code running, however, it seems to run that code on C:\Python312\python.exe
by default.
I found that I could instead set spawn to "wsl", to tell Node to run WSL commands. I then passed the path to the virtual environment and the script as arguments, so it would run both, allowing the script to run in the WSL virtual environment. That ended up looking like this:
const venvPath="./py/.venv/bin/python3"
const scriptPath='./py/routes.py'
flaskProc = require('child_process').spawn("wsl", [venvPath,scriptPath]);
Thank you so much to everyone who helped out