Software⏱️ 2 min read📅 2026-05-31

How to Fix: Failed to activate virtualenv with pyenv

Pyenv-virtualenv not loaded into shell properly. Restart current shell and try again.

Quick Answer: Try restarting the current shell and re-run the command to activate virtualenv.

If you are getting the error 'Failed to activate virtualenv' when using pyenv, it is likely due to pyenv-virtualenv not being loaded into your shell properly. This can happen if you haven't run `source ~/.pyenv/bin/pyenv-sh` or `exec $SHELL` after installing pyenv-virtualenv.

🔧 Proven Troubleshooting Steps

Method 1: Reload Your Shell Configuration

  1. Step 1: Run `source ~/.pyenv/bin/pyenv-sh` or `exec $SHELL` to reload your shell configuration.

Method 2: Reinstall pyenv-virtualenv

  1. Step 1: Run `pyenv install virtualenv` to reinstall pyenv-virtualenv.

✨ Wrapping Up

By following these steps, you should be able to resolve the 'Failed to activate virtualenv' error and successfully activate virtualenv using pyenv.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions