Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Command Line Python Change Version

Tags:

python

New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4)

How can I run my python setup.py build/install on 2.6 instead?

Many thanks in advance,

Brock

like image 262
Btibert3 Avatar asked Jul 06 '10 18:07

Btibert3


People also ask

How do I change the version of Python on Windows?

Yes, you should be able to switch between python versions. As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed.

How do I switch between versions in Python?

Now any time you want to run particular version, just change its order (path) and move it to top of other version, and then restart the cmd and type python this time, you will see that only that particular version of python will run.


2 Answers

You can use explicit paths:

c:\python26\python setup.py install
c:\python25\python setup.py install

Recent versions of Python install PyLauncher. It is installed in the path so no need to add an explicit Python to the path, and it allows easy switching between multiple Python versions.

Examples:

py -3 setup.py # run latest Python 3
py -2 setup.py # run latest Python 2
py -3.3
py -2.7-32 # use 32-bit version
py # run default version

The default version can be specified in the environment variable PY_PYTHON, e.g. PY_PYTHON=3 (latest Python 3).

like image 152
Mark Tolonen Avatar answered Oct 19 '22 23:10

Mark Tolonen


It depends on your operating system. If you have python 2.6 installed, you need to change your environment path to point to the 2.6 executable rather than the 2.5 executable. Do a Google search for changing your PATH variable on your operating system.

like image 31
Alex Bliskovsky Avatar answered Oct 19 '22 23:10

Alex Bliskovsky