[Python] Running systemd service from python script that requires env (uv)

Discussão em 'Python' iniciado por Stack, Julho 15, 2025.

  1. Stack

    Stack Membro Participativo

    Ubuntu 20.04 | env: uv | Python3

    I'm leveraging uv to manage all of my packages for a project. I want to always be collecting data for this project, and I have a simple data_collection.py I'd like to run always, even after restart, using a system service.

    I can confirm that uv run data_collection.py works when ran from /my_ws/src, but the following service script does not run:

    Description=Run the data collection python script on boot - should be always collecting data from RSS feeds
    After=network.target

    [Service]
    Type=simple
    ExecStart=/usr/bin/python3 /home/my_user/src/my_ws/src/data_collection.py
    WorkingDirectory=/home/my_user/src/my_ws/src/
    User=my_user
    Restart=always
    RestartSec=5

    [Install]
    WantedBy=multi-user.target


    Is there a tag I need to add to my service file to specify use of the uv environment? Any best practices are appreciated.

    Continue reading...

Compartilhe esta Página