pyenv-virtualenv: pyenv-virtualenv initialisation failing.

When running $ eval "$(pyenv virtualenv-init -)", I always get this error message:

Failed to deactivate virtualenv.

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

For some reason, I can still use it on the same shell I installed it in, but not any other shell. How do I load up pyenv-virtualenv properly? Note: I Installed it using Homebrew.

I just realised I have issues with my virtualenv:

$ python
-bash: /Users/ncopty/.pyenv/versions/finprod/bin/python: No such file or directory
$ ~/.virtualenvs/finprod/bin/python
Python 2.7.2 (default, Jul  2 2014, 14:30:17) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.34.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Which one is the correct one and why do I have two?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 1
  • Comments: 19 (3 by maintainers)

Commits related to this issue

Most upvoted comments

You did the same mistake that I did. You also need eval "$(pyenv init -)" before the virtualenv-init

I was having trouble activating virtual environments due to same error mentioned in the original post. Adding the following to .zshrc worked for me.

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

@ankitjain87 and @Githeo If you haven’t already given up I was able to get fish working by adding

status --is-interactive; and source (pyenv init -|psub) status --is-interactive; and source (pyenv virtualenv-init -|psub)

If you installed pyenv-virtualenv using Homebrew.

To my fish config. ~/.config/fish/config.fish

I used the instructions from README, installed via brew and added eval "$(pyenv virtualenv-init -)" in .zshenv.

I figured it out. The issue is that I had the initialisation set in .bash_profile. It needs to be set in .bashrc in Mac OS X if it one maintains both configs separately. I’ll add a pull request with changes to the README.

I’m still getting this issue. Any fix / work-around?