0

I would like to run a script as a systemd service, the script is a bash wrapper script that runs a python script. The python script needs to run in a specific conda environment.

I have tried setting the conda environment in the bash script just before running the python command, I get errors of unknown packaged names because the environments have not been altered by conda activate.

What I found funny is that I have also source ~/.bashrc and output the content of $PATH in a log file to check if $PATH has been altered in the script and the answer is no...

script.sh

#!/bin/bash
source ~/.bashrc
conda activate my_env
echo "$PATH" >> ~/log
python3 ~/my_python_script.py

test.service (in ~/.config/systemd/user

[Unit]
Description=Testing

[Service]
Type=simple
ExecStart=/path/to/script.sh
Abitbol
  • 230
  • 1
  • 11
  • 2
    Possible duplicate of [How to run a command inside a virtualenv using systemd](https://unix.stackexchange.com/questions/409609/how-to-run-a-command-inside-a-virtualenv-using-systemd) – Bart Jul 15 '19 at 18:03
  • I hasd other environments to pass as well, so even though it seems that I was asking specificly for conda, the question was about environments in general. Sorry for not having been clear enough. – Abitbol Jul 16 '19 at 08:57

0 Answers0