简体   繁体   中英

Local python version not changing after installing pyenv-win

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

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.

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

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

I wanted to further @nhieckqo answer but don't have the required rep yet, so...

After deleting the paths entries from a system install of python3.9 via Windows Store, I also had to disable ALL aliases for python3.9 (not just App Installer as the pyenv github suggests).

See "NOTE" here:
https://github.com/pyenv-win/pyenv-win/tree/057ba9e97bc5f217ddcffc01768174495c78859a#finish-the-installation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM