~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Systemd with Python environments

Published on

Updated on

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

It took me some time to realize why I couldn’t start a project during startup. I then realized that it was because I was using a python virtual environment and didn’t tell systemd about it.

Here’s how you can do so…

[Unit]
Description=Start Service
# After=network.target # If you want a python webserver...

[Service]
Type=Simple
User=brandon
WorkingDirectory=/home/brandon/Development
ExecStart=/bin/sh -c ". /home/brandon/Development/pythonenv/bin/activate; /home/brandon/Development/start"

[Install]
WantedBy=multi-user.target
Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :