I have Jupyter lab running as a service in a virtual environment on an Ubuntu machine (24 LTS I think). It works perfectly except that it doesn’t load my PYTHONPATH from ~/.bashrc. Here is the service plist file contents:
[Unit]
Description=JupyterLab Service
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/drkrauss/Dev/venv/bin/jupyter lab --config=/home/drkrauss/.jupyter/jupyter_lab_config.py
#User=drkrauss
#Group=drkrauss
WorkingDirectory=/home/drkrauss/
#Restart=always
RestartSec=10
Restart=on-failure
[Install]
WantedBy=default.target
Interestingly, when I run the command
/home/drkrauss/Dev/venv/bin/jupyter lab
in a terminal after login, the PYTHONPATH is read correctly. I think that is just saying that running the command in a terminal means .bashrc has already been sourced. So I guess the service doesn’t source .bashrc first???
I am fairly surprised that googling around has not lead to a good answer.
Ideally I would love to source my .bashrc file before starting the juptyer lab server, but if I had to maintain a separate PYTHONPATH, I could live with that.
How do I set PYTHONPATH for Jupyter lab running in a venv as a service?
Thanks,
Ryan