• Python


    Install Python2 and Python3

    Python 2.7.13 - Windows x86-64 MSI installer
    Python 3.6.0 - Windows x86-64 executable installer
    Note: For Python 3.3 and later, select the option "Install launcher for all users(recommended)".

    Set Environment Variables
    Sample:
    C:Python27;C:Python27Scripts;C:Python27Libsite-packages;
    C:Python36;C:Python36Scripts;C:Python36Libsite-packages;

    Python Launcher for Windows Version

    Python Launcher for Windows Version

    >py -2
    Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
    >py -3
    Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

    Run an sample

    Method 1 : python or py

    >python --version
    Python 2.7.13
    
    >py --version
    Python 3.6.0
    

    Method 2 : py -2 or py -3

    >type HelloWorld-py2.py
    print 'Hello World! Hello Python!'
    >
    >py -2 HelloWorld-py2.py
    Hello World! Hello Python!
    
    
    >type HelloWorld-py3.py
    print ('Hello World! Hello Python!')
    >
    >py -3 HelloWorld-py3.py
    Hello World! Hello Python!
    >
    

    Note:py -2.7 HelloWorld-py2.py and py -3.6 HelloWorld-py3.py are recommended.

    Method 3 : Specify the Python version in a script

    >type HelloWorld-py2.py
    #! python2.7
    print 'Hello World! Hello Python!'
    >
    >py HelloWorld-py2.py
    Hello World! Hello Python!
    
    
    >type HelloWorld-py3.py
    #! python3.6
    print ('Hello World! Hello Python!')
    >
    >py HelloWorld-py3.py
    Hello World! Hello Python!
    >
    

    pip2 and pip3

    Install Python2 Package: pip2 install <Package_name> or py -2 -m pip install <Package_name>
    Install Python3 Package: pip3 install <Package_name> or py -3 -m pip install <Package_name>

    upgrade pip2:py -2 -m pip install --upgrade pip
    upgrade pip3:py -3 -m pip install --upgrade pip

    >pip2 --version
    pip 9.0.1 from c:python27libsite-packages (python 2.7)
    
    >pip3 --version
    pip 9.0.1 from c:python36libsite-packages (python 3.6)
    
    

    Run an sample

    >pip3 list --format=legacy
    pip (9.0.1)
    setuptools (28.8.0)
    
    >pip3 install requests --proxy=10.144.1.10:8080
    Collecting requests
      Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)
        100% |████████████████████████████████| 593kB 137kB/s
    Installing collected packages: requests
    Successfully installed requests-2.13.0
    
    >pip3 list --format=legacy
    pip (9.0.1)
    requests (2.13.0)
    setuptools (28.8.0)
    
    

    py help

    $ py -h
    Python Launcher for Windows Version 3.6.150.1013
    
    usage: py [ launcher-arguments ] [ python-arguments ] script [ script-arguments ]
    
    Launcher arguments:
    
    -2     : Launch the latest Python 2.x version
    -3     : Launch the latest Python 3.x version
    -X.Y   : Launch the specified Python version
    -X.Y-32: Launch the specified 32bit Python version
    
    ......
    
  • 相关阅读:
    LeetCode 560 和为 K 的子数组
    idea使用技巧汇总
    【Kafka核心技术与实战】导读
    如何永久关闭 Mybase8 登录弹窗(license提醒)
    分析Edk2启动流程
    OEE计算
    线段树分治学习笔记
    linux 安装PostgreSql 12[转]
    Linux中redis数据备份和迁移【转】
    DataGrid控件自动显示行号
  • 原文地址:https://www.cnblogs.com/anliven/p/6394519.html
Copyright © 2020-2023  润新知