如何将Python 3.3添加到Powershell? [英] How do I add Python 3.3 to Powershell?
问题描述
嘿,我一直在尝试通过将路径中的33替换为27来将Python 3.3添加到Windows powershell中.
Hey I've been trying to add Python 3.3 to windows powershell by repacing 27 with 33 in the path.
我试图发布屏幕截图,但事实证明我需要10次重复,所以我只复制并粘贴尝试过的内容:
I tried to post a screenshot but turns out I need 10 rep so I'll just copy and paste what I've attempted:
[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33", "User")
>
[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33")
>
[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33\python.exe", "User")
>
[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33;C:\Python33\Scripts", "User")
>
[Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33\", "User")
python.exe所在的文件夹的路径为:C:\ Python33
The path to the folder where python.exe resides is: C:\Python33
我在某处做错了事,但不确定在哪里. 帮助一个家伙进军编程吗?
Somewhere I'm doing something wrong but am not sure where. Help a fellow out with his foray into programming?
谢谢.
推荐答案
Python 3.3附带了PyLauncher(py.exe),该文件安装在C:\ Windows目录中(已经在路径中),并使任何已安装的Python能够通过命令行执行,如下所示:
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.
>>>
请注意,如果同时安装了2.X和3.X,则默认的Python为2.X(在更高版本的Python中为3.X),但是可以使用-3
开关覆盖此默认值,或者将默认值更改为设置PY_PYTHON
环境变量.
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.
此外,如果您最后安装了Python 3.3并注册了扩展名,则PyLauncher将是.py文件的默认程序,并在脚本顶部添加特殊的#!
注释将指定用于该脚本的Python版本.这样一来,您就可以在桌面上使用Python 2和Python 3文件,只需双击它们即可为该脚本运行正确版本的Python.
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.
请参见适用于Windows的Python启动器在 Python 3文档中.
这篇关于如何将Python 3.3添加到Powershell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!