Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyenv-virtualenv initialisation failing. #36

Closed
nayefc opened this issue Jul 7, 2014 · 19 comments
Closed

pyenv-virtualenv initialisation failing. #36

nayefc opened this issue Jul 7, 2014 · 19 comments

Comments

@nayefc
Copy link

nayefc commented Jul 7, 2014

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?

@nayefc
Copy link
Author

nayefc commented Jul 8, 2014

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.

@nayefc
Copy link
Author

nayefc commented Jul 8, 2014

Not completely. Now I can create a virtualenv and list it. But I cannot activate one using pyenv. When activating, I get:

Failed to deactivate virtualenv.

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

Any ideas how to fix/debug? I removed all instances of virtualenv that I had installed manually, I re-installed this package using brew. The output of declare -f pyenv is empty.

I still have a shell that somehow still works (declare -f shows virtualenvwrapper there which is what I had before). But the newer shells I started up and did this clean up and re-installation with don't work. The way I'm working now using that old shell but I need to be able to get it working from a fresh new shell.

@nayefc nayefc closed this as completed Jul 9, 2014
@silvansky
Copy link

Have same here. Why did you close issue? Found a workaround?

@nayefc
Copy link
Author

nayefc commented Jul 15, 2014

@silvansky Yes. How did you install pyenv and pyenv-virtualenv? Also paste anything you've added to your bash_profile related to the, here.

@silvansky
Copy link

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

@nayefc
Copy link
Author

nayefc commented Jul 15, 2014

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

@silvansky
Copy link

Wow! I wish this info was in README... Thanks a lot!

@TimFletcher
Copy link

@nayefc Thanks so much for that comment! I'd been editing and removed eval "$(pyenv init -)"!

@tkhieu
Copy link

tkhieu commented Jan 6, 2015

Thanks @nayefc This bug take me 30m to solve

aristide-n added a commit to aristide-n/pyenv-virtualenv that referenced this issue Jul 27, 2015
@aristide-n
Copy link
Contributor

My PR adds @nayefc's tip to README.

@ankitjain87
Copy link

ankitjain87 commented Apr 19, 2017

I am getting the same error when I am trying to activate in fish shell, but working fine in bash.

Also, when I am trying to activate using direct command activate.fish, I am getting this error -

The file '.pyenv/versions/my_project/bin/activate.fish' is not executable by this user

How can I make it working in fish shell

@Githeo
Copy link

Githeo commented Apr 25, 2018

Same error as @ankitjain87 here.

@bradleyhurley
Copy link
Contributor

@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

@Githeo
Copy link

Githeo commented Aug 21, 2018

Thanks @bradleyhurley, it works!
I hope your trick will be included in the doc.

@bradleyhurley
Copy link
Contributor

I opened a PR - #280

@geoidesic
Copy link

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

@edmarjsg
Copy link

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 -)"

@brianjuhl
Copy link

@imedmar -- THANK YOU!!

@btphan95
Copy link

btphan95 commented Jun 4, 2020

@nayefc Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests