pyenv: failed to activate virtualenv - settings not read from .profile at login

1.1k Views Asked by At

This is a known topic, almost similar to this one.

However - why am I having the pyenv settings passed in ok from .profile at login only up to the virtualenv string.

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi
  eval "$(pyenv virtualenv-init -)"

After login, the above portion is read (pyenv is active in terminal) but not virtualenv. Manual activation of the venv produces the well-known error message.

$pyenv activate venv_name

Failed to activate virtualenv.

Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.

I can solve this by explicitly sourcing .profile - then it works fine. But why would .profile not be read or interpreted at once at login?

Modifying .bashrc takes no effect. Seems like it's not being read. But .profile is. Global python is system (2.7).

Take care

1

There are 1 best solutions below

0
aibohphobia On

Try pyenv init --path instead of pyenv init - and again putting it in bashrc.