gpt4 book ai didi

python - 如何将 Python 3.3 添加到 Powershell?

转载 作者:太空宇宙 更新时间:2023-11-04 07:09:16 24 4
gpt4 key购买 nike

嘿,我一直在尝试通过将路径中的 27 替换为 33 来将 Python 3.3 添加到 windows powershell。

我尝试发布屏幕截图,但结果我需要 10 个代表,所以我只复制并粘贴我尝试过的内容:

[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

我在某个地方做错了,但不确定在哪里。帮助一个人尝试编程?

谢谢。

最佳答案

Python 3.3 附带 PyLauncher (py.exe),它安装在 C:\Windows 目录(已在路径中),并使任何已安装的 Python 都可以通过命令行执行,如下所示:

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 环境变量来切换或更改默认值。

此外,如果您最后安装 Python 3.3 并注册扩展,PyLauncher 将成为 .py 文件的默认程序,并在脚本顶部添加特殊的 #! 注释将指定版本用于脚本的 Python。这允许您在桌面上拥有 Python 2 和 Python 3 文件,只需双击它们即可为该脚本运行正确版本的 Python。

参见 Python Launcher for WindowsPython 3 docs .

关于python - 如何将 Python 3.3 添加到 Powershell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20364207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com