Skip to main content

pyenv 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.

Project description

pyenv for Windows

pyenv is a great tool. We have ported it to Windows. We need your thoughts to improve this library and your feedback helps to grow.

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, they help us a lot.

License: MIT GitHub issues open Downloads

Important Announcements

To keep in sync to pyenv linux/mac we changed the default version to 64bit Architecture as a main track. To support older version of pyenv-win i.e. 32bit Architecture as a seperate track.

Both the tracks supports installation of 64bit and 32bit python versions, the change in these tracks are python naming as shown below.

64bit-train or master i.e. 2.64.x

> pyenv install -l 
....
3.8.0-win32
3.8.0
3.8.1rc1-win32
3.8.1rc1
3.8.1-win32
3.8.1
3.8.2-win32
3.8.2
....

32bit-train i.e. 2.32.x

>pyenv install -l 
....
3.8.0
3.8.0-amd64
3.8.1rc1
3.8.1rc1-amd64
3.8.1
3.8.1-amd64
3.8.2
3.8.2-amd64
....

Introduction

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. pyenv-win is getting mature every day thanks for the contributors and supports.

pyenv

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.

pyenv-win commands

   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 1 or more versions of Python 
   uninstall    Uninstall 1 or more versions of Python
   update       Update the cached version DB
   rehash       Rehash pyenv shims (run this after switching Python versions)
   vname        Show the current Python version
   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
   which        Display the full path to an executable
   whence       List all Python versions that contain the given executable

Installation

Get pyenv-win

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 $HOME\.pyenv
    • cmd.exe: pip install pyenv-win --target %USERPROFILE%\.pyenv
  • With zip file
    1. Download link: pyenv-win
    2. Extract to
    • Powershell or Git Bash: ~/.pyenv/pyenv-win
    • cmd.exe: %USERPROFILE%\.pyenv\pyenv-win
    1. Ensure you see bin folder under pyenv-win
  • 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
  • With Chocolatey
    • choco install pyenv-win (this also installs all the environment variables)

Finish the installation

NOTE: If you are running Windows 10 1905 or newer, you made need to disable the built-in Python launcher via Start > "Manage App Execution Aliases" and disabling the "App Installer" aliases for Python

If you installed using Chocolatey, you can skip to step 3.

  1. Add PYENV to your Environment Variables

    1. Using either PowerShell or Windows Terminal run
    [System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
    
  2. Now add the following paths to your USER PATH variable in order to access the pyenv command. Run the following in PowerShell or Windows Terminal:

    [System.Environment]::SetEnvironmentVariable('path', $HOME + "\.pyenv\pyenv-win\bin;" + $HOME + "\.pyenv\pyenv-win\shims;" + $env:Path,"User")
    
  3. Close and reopen your terminal app and run pyenv --version

    1. If the return value is the installed version of pyenv, then contonue to Step 4
    2. If you receive a command not found error, ensure the environment variables are properly set via the GUI: This PC → Properties → Advanced system settings → Advanced → Environment Variables... → PATH
  4. Now run the pyenv rehash from home directory

  5. Run pyenv to see list of commands it supports. More info...

Installation is done. Hurray!

32bit-train Support

  • With Git

    • change directory to %USERPROFILE%\.pyenv via cd
    • run following command git checkout -b 32bit-train origin/32bit-train
    • now run pyenv --version you need to see 2.32.x
  • With pip

    • Powershell or Git Bash: pip install pyenv-win==2.32.x --target $HOME\.pyenv
    • cmd.exe: pip install pyenv-win==2.32.x --target %USERPROFILE%\.pyenv
  • With zip file

    1. Download link: pyenv-win
    2. Extract to
    • Powershell or Git Bash: ~/.pyenv/pyenv-win
    • cmd.exe: %USERPROFILE%\.pyenv\pyenv-win
    1. Ensure you see bin folder under pyenv-win

Now follow finish the installation which are above

Usage

  • Update the list of discoverable Python versions: pyenv update
  • 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: An install wizard may pop up for some non-silent installs. You'll need to click through the wizard during installation. There's no need to change any options in it. or you can use -q for quite installation
    • You can also install multiple versions in one command too: pyenv install 2.4.3 3.6.8
  • 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.
  • After (un)installing any libraries using pip or modifying the files in a version's folder, you must run pyenv rehash to update pyenv with new shims for the python and libraries' executables.
    • Note: This must be run outside of the .pyenv folder.
  • 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

How to get updates

  • 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
  • If installed via Git
    • Go to the %USERPROFILE%\.pyenv\pyenv-win (which is your installed path) and run git pull
  • If installed via zip
    • Download the latest zip and extract it
    • Go to %USERPROFILE%\.pyenv\pyenv-win and replace the folders libexec and bin with the new ones you just downloaded

FAQ

  • Question: Does pyenv for windows support python2?

    • Answer: Yes, We support python2 from version 2.4+ until python.org officially removes it.
    • Versions below 2.4 use outdated Wise installers and have issues installing multiple patch versions, unlike Windows MSI and the new Python3 installers that support "extraction" installations.
  • 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.
  • Question: System is stuck while uninstalling the python version, what to do?

    • Answer: Navigate to the location you installed pyenv, opening its 'versions' folder (usually %USERPROFILE%\.pyenv\pyenv-win\versions), and delete the folder of the version you want removed.
  • 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
  • Question: pyenv-win not recognised, but I have set the ENV PATH?

    • Answer: According to Windows when adding the path under the User or System variables, for the User variable you need to logout and login again to reflect the changes. For System variable it's not required.

Change Log

New in 2.64.2

  • Version naming conventions have now changed from using 64-bit suffixes when specifying a version to (un)install. Now all you need to use is the version number to install your platform's specifc bit version.
    • *WARNING*: This change is backwards incompatible with v1.2.5 or less so please install 32bit-train which is backward compatible or uninstall all versions of python prior to upgrading pyenv to this version.
    • Ex. pyenv install 2.7.17 will install as 64-bit on x64 and 32-bit on x86. (64-bit can still use 2.7.17-win32 to install the 32-bit version)
    • pyenv global/local/shell also now recognize your platform and select the appropirate bit version. (64-bit users will need to specify [version]-win32 to use the 32-bit versions now)
  • Added support for true unobtrusive, local installs.
    • *WARNING*: This change is backwards incompatible with v1.2.5 or less so please install 32bit-train which is backward compatible or uninstall all versions of python prior to upgrading pyenv to this version.
    • No install/uninstall records are written to the registry or Start Menu anymore (no "Programs and Features" records).
    • When installing a patch version of python (ex. 3.6.1) installing another patch version (ex. 3.6.2) won't reuse the same folder and overwrite the previously installed minor version. They're now kept separate.
    • Uninstalls are now a simple folder deletion. (Can be done manually by the user safely now or pyenv uninstall)
  • Added support for (un)installing multiple versions of python in a single command or all DB versions via the -a/--all switch.
    • When using --all on x64 computers you can use --32only or --64only to install only 32-bit or only 64-bit version s of python. (Does nothing on 32-bit computers, and better filters may be in the works later on)
  • pyenv global/rehash is called automatically after (un)installing a new Python version. (last version specified, if installing multiple)
  • Pyenv now uses a cached DB of versions scraped straight from the Python mirror site and can be updated manually by a user using pyenv update. Users no longer have to wait for pyenv's source repo to be updated to use a new version of Python when it releases, and can also use the new alpha/beta python releases.
  • pyenv install now has a -c/--clear to empty cached installers in the %PYENV%\install_cache folder.
  • pyenv rehash now acknowledges %PATHEXT% (plus PY and PYW) when creating shims instead of just for exe, bat, cmd and py files so more executables are available from \Scripts and libraries installed using pip.
  • Shims created using pyenv rehash no longer call pyenv exec, but instead call python directly to prevent issues with other programs executing the shims.
  • Shims now use cp1250 as the default code page since Python2 will never actually support cp65001. cp1250 has better support for upper ANSI characters (ex. "Pokémon"), but still isn't full UTF-8 compatible.
  • Note: Support for Python versions below 2.4 have been dropped since their installers don't install "cleanly" like versions from 2.4 onward and they're predominently out of use/support in most envrionments now.

How to contribute

  • 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 and tests\test_uninstall.bat
  • Push to your origin repository.
  • Create a new Pull Request in GitHub.

Bug Tracker and Support

  • Please report any suggestions, bug reports, or annoyances with pyenv-win through the GitHub bug tracker.

License and Copyright

  • pyenv-win is licensed under MIT 2019

    License: MIT

Author and Thanks

pyenv-win was developed by Kiran Kumar Kotari and Contributors
Thanks for all Contributors and Supports for patience for the latest major release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyenv-win, version 2.64.2
Filename, size File type Python version Upload date Hashes
Filename, size pyenv_win-2.64.2-py3-none-any.whl (37.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyenv-win-2.64.2.tar.gz (34.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page