Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active January 4, 2016 08:09
Show Gist options
  • Save CMCDragonkai/8593336 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/8593336 to your computer and use it in GitHub Desktop.
CONFIGURATION: Windows: Python 2 & 3 coexisting

Python 2 and 3

When installing Python 2 and Python 3 on a Windows computer. The environment variables determine which one to use.

So one of the python executables may be on the PATH. You can rename the python executable such as python27.exe or python33.exe.

Then you can execute them like python27 or python33 on the CLI.

However when Python launches it utilises certain environment variables to get its dependencies.

The environment variable on Windows is PYTHONHOME.

Change PYTHONHOME to which the directory which houses the python executable.

To do so via CMD:

Show all environment variables.

SET

Set the environment variable.

SET PYTHONHOME=C:\python33

To do so via PowerShell:

Show all environment variables.

Get-ChildItem Env:

Set the environment variable.

$env:TestVariable = "This is a test environment variable."

To do permanent environment variable setting:

Use setx http://technet.microsoft.com/en-us/library/cc755104.aspx

This works for both CMD and Powershell

This require a restart on the terminal.

Paths

You will also need to change the paths to the python executable and the python Scripts folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment