I installed pyenv-virtualenv
using Linuxbrew (Homebrew 2.2.5) on my Ubuntu 16.04 VPS. The pyenv version is: 1.2.16
. Now when I do a test like this:
pyenv install 3.8.1
pyenv virtualenv 3.8.1 test
cd /.pyenv/versions/3.8.1/envs/test
pyenv local 3.8.1
Then entering / leaving the /.pyenv/versions/3.8.1/envs/test
doesn't activate deactivate the virtual environment and I don't see (test) username:~
in my shell. I also created a /home/users/test
directory and .python-version
there but still entering / leaving directory does nothing.
Accordingn to the documentation:
If eval "$(pyenv virtualenv-init -)" is configured in your shell, pyenv-virtualenv will automatically activate/deactivate virtualenvs on entering/leaving directories which contain a .python-version file that contains the name of a valid virtual environment as shown in the output of pyenv virtualenvs (e.g., venv34 or 3.4.3/envs/venv34 in example above) . .python-version files are used by pyenv to denote local Python versions and can be created and deleted with the pyenv local command.
So first question is: Why this doesn't work? Why the virtual environment is not activated / deactivated automatically at entering / leaving a directory containing a .python-version
file?
Also when I activate virtualenv by hand pyenv activate test
and then check the Python version, it prints the system Python version and not the one from environment: Python 3.8.1
:
python --version
Python 3.7.6
I can get the right Python version only by directly referring to virtualenv shims Python like this:
which python
/home/andre/.pyenv/shims/python
/home/andre/.pyenv/shims/python --version
Python 3.8.1
The behaviour is the same whenever the virtualenv "test" is activated or not.
I would expect that after activating "test" the command python --version
returns Python 3.8.1
So second question: why pip
and python
are not switched when activating / deactivating the virtual environment ?
Are these pyenv bugs? Or am I doing something wrong?