B
B
bsbak2020-06-11 10:15:48
linux
bsbak, 2020-06-11 10:15:48

How to start a service with pyenv loading in linux?

If I write lines in interactive mode:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate nyaa
cd /home/nyaa
python run.py


then everything starts up and works...
If I add these lines to the .service file and run it, it gives an error:
pyenv: no such command `virtualenv-init'
and
pyenv: no such command `activate'

.service (I start in 1 line )
ExecStart=/bin/sh -c 'export PATH="$HOME/.pyenv/bin:$PATH" && eval "$(/root/.pyenv/bin/pyenv init -)" && eval "$(/root/.pyenv/bin/pyenv virtualenv-init -)" && /root/.pyenv/bin/pyenv activate nyaa && cd /home/nyaa && python run.py'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Berkutman, 2020-06-11
@Berkutman

ExecStart=/bin/bash /root/script.sh
ls /root/script.sh cat
script.sh

#!/bin/bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate nyaa
cd /home/nyaa
python run.py

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question