Local python version not changing after installing pyenv-win

Viewed 4860

I've recently installed pyenv-win on my Windows machine using the pip documentation as I already had Python 3.8.5 installed on my machine. Having used pyenv to set the global version to 3.7.6:

  • Running pyenv which python returns C:\Users\Haydn\.pyenv\pyenv-win\versions\3.7.6\python.exe as expected
  • However, running python -V returns Python 3.8.5
  • and pip -V returns pip 20.2.2 from C:\Users\Haydn\AppData\Roaming\Python\Python38\site-packages\pip (python 3.8)

Installing other packages such as pipenv does so in the Python 3.8 folder and fails, as do projects requiring Python 3.7. I'm trying to work out what I could have done wrong or might not be working so that the pyenv 3.7 version is used over the system 3.8.


Everything seems to have progressed fine during installation:

  • pyenv --version returns pyenv 2.64.3
  • Environment variable PYENV is set to C:\Users\Haydn\.pyenv\pyenv-win\
  • C:\Users\Haydn\.pyenv\pyenv-win\bin & C:\Users\Haydn\.pyenv\pyenv-win\shims are added to the Path environment variable.

I don't know much about environment variables, but my suspicion is towards the fact that installing Python 3.7 using pyenv has not added anything to my Path variable (see screenshot), so when I call python it's just moving into the 3.8 folder as expected. I feel like pyenv should have added something here but that may not be how the package works and something else could very well be the cause.

screenshot of Path variable

Thanks in advance for your help

4 Answers

Python installed path that was set in environment variables PATH seems override the pyenv-win configuration. If any Python installation directory was previously set in PATH try deleting it as pointed out in this: pyenv global interpreter not working on windows10

pyenv rehash seem to do the trick for me. I've had similar issue where Path did not get pointed at proper python installation. Rehashing fixed the issue.

There was also other issue reported on pyenv-win github: https://github.com/pyenv-win/pyenv-win/issues/67 But that seem to be resolved already - rehash was actually an idea from there.

Every virtualenv is self-contained with its own copy of python, and libs. Hence, this is why you're seeing the behaviour you are.

Related