8

I've been using pyenv for a long time, without any troubles. I set up it properly and everything worked.

However, while I was trying to solve another problem, I run some line which ruined my pyenv instalation.

Now, when I activate any virtualenv, it tries to use system's python instead of pyenv's:

$ pyenv activate foo
(foo) $ which python 
/usr/bin/python
(foo) $ pip --version
pip 20.3.4 from /home/rodrigo/.local/lib/python2.7/site-packages/pip (python 2.7)

I'm not sure exactly which line was the one that ruined it, it may be the following: (foo) $ pip install --upgrade pip setuptools wheel from the foo environment (I run it when it still worked), but may be another.

I already checked ~/.bashrc file and it is ok; restarted the console and even changed to a different environment foo2 and the problem is still there...

I already checked similar questions like this or this, but those are related to miss-configurations which I already tested and are ok.

I'm using Ubuntu 18.04 LTS and pyenv 2.0.3-8-gad880754

UPDATE I re-installed pyenv but it still doesn't work

1 Answer 1

7

I got it to work by changing ~/.zshrc:

Change

eval "$(pyenv init -)"

to

eval "$(pyenv init --path)"

and start a new shell.

Seems like this was a change that was introduced in 2.0.

Sign up to request clarification or add additional context in comments.

9 Comments

awesome. This fixed the problem for me
I keep getting Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again. with this change.
This error suggests that pyenv-virtualenv might not have been correctly loaded into your shell.
To resolve this, follow these steps
eval "$(pyenv virtualenv-init -)”
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.