Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyenv is using system python instead of virtual environment

Tags:

python

pip

pyenv

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

like image 507
Rodrigo Laguna Avatar asked Jun 26 '26 21:06

Rodrigo Laguna


1 Answers

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.

like image 128
FuQiang Avatar answered Jun 28 '26 09:06

FuQiang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!