pyenv is a great tool. I ported it to Windows. Some commands aren't implemented, but it's good enough for basic use.
For existing python users, we support installation via pip: follow instructions
Contributors and Interested people can join us @Slack We need your help on motivating us and your thoughts, they help us a lot.
Note: We do keep in sync to pyenv versions. We are planning to move the default version as 64-bit from 32-bit, and 32-bit will be followed by <version>-Win32
. We are trying our best to keep the existing master (i.e. default 32-bit) as separate active train for existing users. So please don't be shocked when the master changes to 64-bit by default. Hope you understand, we will keep posting when they are active and how to use default 32-bit train as well.
- Introduction
- pyenv
- pyenv-win commands
- Installation
- Usage
- How to get updates
- FAQ
- How to contribute
- Bug Tracker and Support
- License and Copyright
- Author and Thanks
pyenv for python is a great tool but, like rbenv for ruby developers, it doesn't support Windows directly. After a bit of research and feedback from python developers, I discovered they wanted a similiar feature for Windows systems.
I got inspired from the pyenv issue for Windows support. Personally, I use Mac and Linux with beautiful pyenv, but some companies still use Windows for development. This library is to help Windows users manage multiple python versions.
I found a similar system for rbenv-win for ruby developers. This project was forked from rbenv-win and modified for pyenv. Some command aren't implemented, but it's good enough for basic use.
pyenv is a simple python version management tool. It lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall Uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
exec Runs an executable by first preparing PATH so that the selected Python
Get pyenv-win via one of the following methods:
- With pip (to support existing python users)
- Powershell or Git Bash:
pip install pyenv-win --target ~/.pyenv
- cmd.exe:
pip install pyenv-win --target %USERPROFILE%/.pyenv
- Powershell or Git Bash:
- With zip file
- Download link: pyenv-win
- Extract to
- Powershell or Git Bash:
~/.pyenv/pyenv-win
- cmd.exe:
%USERPROFILE%/.pyenv
- With Git
- Powershell or Git Bash:
git clone https://github.com/pyenv-win/pyenv-win.git ~/.pyenv
- cmd.exe:
git clone https://github.com/pyenv-win/pyenv-win.git %USERPROFILE%/.pyenv
- Powershell or Git Bash:
- With Chocolatey
choco install pyenv-win
(this also installs all the environment variables)
-
If you installed using Chocolatey, you can skip to step 3. Otherwise, add a new System variable and User variable in ENVIRONMENT with name:
PYENV
value:%USERPROFILE%\.pyenv\pyenv-win
Note: A couple of system versions were acting weird, so it's safe to add the %PYENV% in both the locations..! -
Now add the following paths to your System ENVIRONMENT PATH variable in order to access the pyenv command (don't forget to separate with semicolons):
%PYENV%\bin
%PYENV%\shims
This can be done through GUI or command line:
- This PC → Properties → Advanced system settings → Advanced → Environment Variables... → PATH
- Be careful! People who use Windows newer than May 2019 Update must put these items above
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
; See this article. - Powershell:
[System.Environment]::SetEnvironmentVariable('path', "$env:HOME\.pyenv\pyenv-win\bin;$env:HOME\.pyenv\pyenv-win\shims;" + $env:Path, [System.EnvironmentVariableTarget]::User)
-
Verify the installation was successful by opening a new terminal and running
pyenv --version
-
Now run the
pyenv rehash
from home directory- You should see the current pyenv version. If you are getting an error, go through the steps again. Still facing the issue? Open a ticket.
-
Run
pyenv
to see list of commands it supports. More info...
Installation is done. Hurray!
- To view a list of python versions supported by pyenv windows:
pyenv install -l
- To install a python version:
pyenv install 3.5.2
- Note: Older versions of python use an MSI file. You'll need to click through the wizard during installation. There's no need to change any options in it.
- To set a python version as the global version:
pyenv global 3.5.2
- This is the version of python that will be used by default if a local version (see below) isn't set.
- Note: The version must first be installed
- To set a python version as the local version:
pyenv local 3.5.2
.- The version given will be used whenever
python
is called from within this folder. This is different than a virtual env, which needs to be explicitly activated. - Note: The version must first be installed
- The version given will be used whenever
- After (un)installing any python version, you must run
pyenv rehash
to update pyenv with the new python version.- Note: This must be run outside of the
.pyenv
folder
- Note: This must be run outside of the
- To uninstall a python version:
pyenv uninstall 3.5.2
- To view which python you are using and its path:
pyenv version
- To view all the python versions installed on this system:
pyenv versions
- If installed via pip
- Add pyenv-win installed path to
easy_install.pth
file which is located in site-package. Now pyenv-win is recognised by pip - Get updates via pip
pip install --upgrade pyenv-win
- Add pyenv-win installed path to
- If installed via Git
- Go to the
%USERPROFILE%/.pyenv/pyenv-win
(which is your installed path) and rungit pull
- Go to the
- If installed via zip
- Download the latest zip and extract it
- Go to
%USERPROFILE%/.pyenv/pyenv-win/
and replace the folderslibexec
andbin
with the new ones you just downloaded
-
Question: Does pyenv for windows support python2?
- Answer: Yes, We support python2 from version 2.0.1. We support it from 2.0.1 until python.org officially removes it.
-
Question: Does pyenv for windows support python3?
- Answer: Yes, we support python3 from version 3.0. We support it from 3.0 until python.org officially removes it.
-
Question: I am getting the issue
batch file cannot be found.
while installing python, what should I do?- Answer: You can ignore it. It's calling
pyenv rehash
command before creating the bat file in few devices.
- Answer: You can ignore it. It's calling
-
Question: System is stuck while uninstalling the python version, what to do?
- Answer: It's based on the system policies in some computers, recommend to uninstall in these computers by going to the path
%USERPROFILE%/.pyenv/pyenv-win/install_cache/
. I believe you know manual uninstallation. Please remove thesite-package
andscripts
while uninstalling (mandatory). Double check the python version folder doesn't exist in the path%USERPROFILE%/.pyenv/pyenv-win/versions/
if exist please do remove it (mandatory).
- Answer: It's based on the system policies in some computers, recommend to uninstall in these computers by going to the path
-
Question: I installed pyenv-win using pip. How can I uninstall it?
- Answer: Follow the pip instructions in How to get updates and then run
pip uninstall pyenv-win
- Answer: Follow the pip instructions in How to get updates and then run
-
Question: pyenv-win not recognised, but I have set the ENV PATH?
- Answer: According to windows added the path in User or System variable, For User variale you need to logout and login to reflect the path. For System variavle it's not required.
- Fork the project & clone locally.
- Create an upstream remote and sync your local copy before you branch.
- Branch for each separate piece of work. It's a good practise to write test cases.
- Do the work, write good commit messages, and read the CONTRIBUTING file if there is one.
- Test the changes by running
tests\test_install.bat
andtests\test_uninstall.bat
- Push to your origin repository.
- Create a new Pull Request in GitHub.
- Please report any suggestions, bug reports, or annoyances with pyenv-win through the GitHub bug tracker.
-
pyenv-win is licensed under MIT 2019
pyenv-win was developed by Kiran Kumar Kotari and Contributors