First the the basic part about Path,in newer version of Windows installer for Python like 3.5-->.
There is a option under install to
Add Python 3.6 to Path as i show in this
tutorial.
So if start cmd:
Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. Med enerett. C:\Windows\System32>cd\ C:\>python Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> exit() C:\>pip -V pip 9.0.1 from c:\python36\lib\site-packages (python 3.6) C:\>
The
pip install some_package will work from anywhere in cmd and always install to 3.6.
Running
.py files from anywhere in cmd with
python my_scripts.py will always use 3.6
About py Launcher. Python 3.3--> introduces Python Launcher for Windows that is installed into
c:\Windows\ as
py.exe.
This launcher can load any Python version install on your OS.
I usually have 5-6 Python version installed and a main one the newest(3.6) set in Path as show over.
Demo of py launcher:
C:\1 λ py -2.7 version.py Hello from 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] C:\1 λ py -3.4 version.py Hello from 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] C:\1 λ py -3.5 version.py Hello from 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] λ py -3.6 version.py Hello from 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] C:\1 # using py launcher to install into 2.7 λ py -2.7 -m pip install requests Collecting requests Using cached requests-2.18.4-py2.py3-none-any.whl ..... Successfully installed certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22
The
version.py file i am running to show what version is used is this one.
I always use
cmder if you wonder about
λ,a
tutorial.
import sys print('Hello from {}'.format(sys.version))