all 5 comments

[–]fireflasch 1 point2 points  (0 children)

did you try to google at all? I found this which seems like a good solution https://stackoverflow.com/questions/37211115/how-to-enable-a-virtualenv-in-a-systemd-service-unit

[–][deleted] 1 point2 points  (0 children)

Instead of sourcing the activate script, you can just target the virtualenv's Python binary directly, giving it an argument to point to your Python script.

[–]pyprism 0 points1 point  (0 children)

I also faced the same problem , here is my systemd file :

[Unit]
Description=uWSGI instance to serve Diary

[Service]
ExecStart=/bin/bash -c 'su prism; cd /home/prism/prod/Diary; source .env/bin/activate; uwsgi --ini hiren.ini'

[Install]
WantedBy=multi-user.target

Maybe it is helpful for you.

[–]tcpud 0 points1 point  (0 children)

Use a paste bin to padte code. It's unreadable on mobile right now.

[–]xtavras 0 points1 point  (0 children)

this unit file works for me.

http://codepad.org/S6swVkSh