0

I use pyenv in my work and try to automate activation pyenv via bash script.

Normally i use below commands to activate it (it works well):

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"


pyenv activate venv

I try to use bash script to automate it via bash script

Bash script (mybash_script)

#!/bin/bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

pyenv activate venv


then i do

chmod +x ./mybash_script

But when i try to execute it - it doesn't activate pyenv. What i'm doing wrong why it is not working?

dmitriy_one
  • 477
  • 1
  • 5
  • 16

1 Answers1

1

Your Bash script activates your Python environment and exits.

Try running it with source mybash_script.

Aleksey Tsalolikhin
  • 1,518
  • 7
  • 14