Windows Python Command Line Version

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

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

Thank you very much in advance,

Brock

+3
source share
6 answers

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

+4
source

You can use explicit paths:

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

Python PyLauncher. , Python Python.

:

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

PY_PYTHON, . PY_PYTHON=3 ( Python 3).

+5
+1

, . , python, , python . ( )

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
    installpath, installpath, installpath
)

def RegisterPy():
    try:
        reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
    except EnvironmentError:
        try:
            reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
        except Exception, e:
            print "*** Unable to register: %s" % e
            return

    SetValue(reg, installkey, REG_SZ, installpath)
    SetValue(reg, pythonkey, REG_SZ, pythonpath)
    CloseKey(reg)
    print "--- Python %s at %s is now registered!" % (version, installpath)

if __name__ == "__main__":
    RegisterPy()
0

Windows, Python , , Python, :

> python --version
> set PATH=<path-to-desired-python-version>;%PATH%
> python --version

:

> python --version
Python 3.4.2
> set PATH=C:\tools\python2\;%PATH%
> python --version
Python 2.7.9
> npm install...
(success)

This allowed a third-party program to successfully install. Modifying PATH only affects programs running in the same command-line session, and lasts as long as the command-line session.

0
source

Download Python v2.6.

-4
source

Source: https://habr.com/ru/post/1753391/


All Articles