Skip to main content

Windows command-line tool to switch between different installed versions of Python.

Project description

Description

From the Windows command-line, run:

pychoose XY

This will make Python version X.Y active, if it is installed, for subsequent commands from the same prompt. The change is local to this shell.

The prompt is modified to indicate the modified environment.

To revert to the previously used version of Python, type ‘exit’

This works by starting a new Cmd shell with a modified PATH, by prepending C:\PythonXY and its subdirectories, and importantly by removing any other C:\PythonZZ directories and subdirectories.

Multiple invocations of pychoose can be nested.

Dependencies

MS Windows.

Python itself: Can be used to switch TO any version of Python at all (and then back again with ‘exit’.) However, the version of Python you are switching FROM must be from 2.4 to 3.1.

No other dependencies.

Installing

Windows users may download and double-click a graphical installer from http://pypi.python.org/pypi/pychoose.

Command-line jockeys with setuptools installed may use:

easy_install pychoose

or, if pip is installed:

pip install pychoose

or download a zip of the source from http://pypi.python.org/pypi/pychoose and use:

python setup.py install

Alternatively, to check out the latest unstable source from subversion, including tests, see:

http://code.google.com/p/pychoose/source/checkout.

Experiment on WindowsXP shows that pychoose only needs to be installed once, on your default version of Python, not on all installed versions of Python. After running pychoose, it is no longer on your PATH, however the pychoose.bat file is still found by future invocations - presumably all shells have a shared cache of executable locations, or somesuch.

Known Problems

Only works on Windows. Not in a Cygwin shell, nor if Cygwin Python is first on your path, nor on other platforms.

Should get the install dirs of various Python versions from the registry, insted of assuming they are all variations on C:\PythonXX.

Would be much more reliable if we allow the user to pass the directory of the Python version to switch to, instead of trying to be clever and figure it out ourselves.

Can’t switch from versions of Python prior to 2.4, since we use ‘subprocess’ to launch the new shell.

Doesn’t affect Windows .py filetype associations. Perhaps this could be tackled by inserting an environment variable into the registry keys, set the env var in the registry (to persist its default value) and then change that value temporarily and locally in this script.

Haven’t tested how it interacts with virtualenv.

Currently adds all subdirectories of PythonXX to the PATH. This is probably overkill. Can we filter out desired subdirectories with any reliability?

License

Pychoose is distributed under the BSD license. Live long and prosper.

Project details


Download files

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

Source Distribution

pychoose-0.1.3.zip (5.0 kB view details)

Uploaded Source

Built Distribution

pychoose-0.1.3.win32.exe (67.8 kB view details)

Uploaded Source

File details

Details for the file pychoose-0.1.3.zip.

File metadata

  • Download URL: pychoose-0.1.3.zip
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pychoose-0.1.3.zip
Algorithm Hash digest
SHA256 c877263257a1d8d7864b739fa7458145996f42331c3825344858a87165015c46
MD5 fc88556bb5fcaa2f51af72487dbd4031
BLAKE2b-256 e7e76b1aa7ff73a548d51a01d3a2ac4fc798ee00deff2b835f853130b966b755

See more details on using hashes here.

File details

Details for the file pychoose-0.1.3.win32.exe.

File metadata

  • Download URL: pychoose-0.1.3.win32.exe
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pychoose-0.1.3.win32.exe
Algorithm Hash digest
SHA256 f8ce94fb6dc1fa812073a9db491a80ba305705cce794db243ace46140251de5d
MD5 b8fdc15df7f4a121a7fe11dce68dd444
BLAKE2b-256 43fe7c746b32e36654fe74548e7a879c6cc49b54bc2fc5f48de1e5990c679437

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page