close

[Solved] Failed to activate virtualenv with pyenv

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Failed to activate virtualenv with pyenv in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Failed to activate virtualenv with pyenv Error Occurs?

Today I get the following error Failed to activate virtualenv with pyenv in python.

How To Solve Failed to activate virtualenv with pyenv Error ?

  1. How To Solve Failed to activate virtualenv with pyenv Error ?

    To Solve Failed to activate virtualenv with pyenv Error should be in .bashrc, not .bash_profile. The latter is executed only by login shells, the former by all interactive shells.

  2. Failed to activate virtualenv with pyenv

    To Solve Failed to activate virtualenv with pyenv Error should be in .bashrc, not .bash_profile. The latter is executed only by login shells, the former by all interactive shells.

Solution 1

That

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

should be in .bashrc, not .bash_profile. The latter is executed only by login shells, the former by all interactive shells.

Solution 2

  1. Add the lines below to your ~/.bash_profile or ~/.zprofile
eval "$(pyenv init -)"  
eval "$(pyenv virtualenv-init -)"
  1. Restart shell or run the command:
source ~/.bash_profile

Note:

If you are using zsh shell (default for macOS Catalina and/or Big Sur) you have to use ~/.zprofile file rather than ~/.bash_profile

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read