How do I add Python 3.3 to Powershell?

前端 未结 2 697
一向
一向 2021-01-16 08:19

Hey I\'ve been trying to add Python 3.3 to windows powershell by repacing 27 with 33 in the path.

I tried to post a screenshot but turns out I need 10 rep so I\'ll j

2条回答
  •  余生分开走
    2021-01-16 09:16

    Python 3.3 comes with PyLauncher (py.exe), which is installed in the C:\Windows directory (already on the path) and enables any installed Python to be executed via command line as follows:

    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    
    PS C:\> py
    Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> ^Z
    
    PS C:\> py -2
    Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> ^Z
    
    PS C:\> py -3
    Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

    Note that the default Python if both 2.X and 3.X are installed is 2.X (3.X in later versions of Python), but this can be overridden with the -3 switch or the default changed by setting the PY_PYTHON environment variable.

    Also, if you install Python 3.3 last and register extensions, PyLauncher will be the default program for .py files and adding a special #! comment to to top of a script will specify the version of Python to use for the script. This allows you to have Python 2 and Python 3 files on the desktop and just double-click them to run the correct version of Python for that script.

    See Python Launcher for Windows in the Python 3 docs.

提交回复
热议问题