Skip to content

[SOLVED] Getting "Failed to activate virtualenv" when using with pyenv 2.0.0-rc1-2-gac4de222 (cloned on 2021-05-22) #387

@renatocan

Description

@renatocan

I tried update pyenv but I'm getting an error when trying to use pyenv-virtualenv:

Failed to activate virtualenv.

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

I'm using zsh.

Steps to reproduce:

  • Clone pyenv:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
  • Add config to ~/.zshrc:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/repo/prj
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
fi
  • Restart shell and clone pyenv-virtualenv:
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
  • Add pyenv-virtualenv config to ~/.zshrc:
eval "$(pyenv virtualenv-init -)"
  • Restart shell and install a Python version:
pyenv install 3.9.5
  • Create a virtualenv:
pyenv virtualenv 3.9.5 py3

Try to activate it:

pyenv activate py3

When using pyenv 1.2.26, the problem does not occur (in that case, we must initialize pyenv using pyenv init - instead of pyenv init --path).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions