gpt4 book ai didi

python - 第一次尝试从 Powershell 运行 python。我使用的命令是否正确/我需要做什么才能允许使用 Python?

转载 作者:太空宇宙 更新时间:2023-11-03 20:38:41 26 4
gpt4 key购买 nike

我正在尝试使用 PowerShell 从命令行运行一些 Python 文件,但我真的不熟悉 shell,并且在尝试运行 python 时遇到了一些问题。我认为我错过了一些Python的准备过程,但我不知道是什么。

在尝试通过 Powershell 运行 Python 时,我尝试在计算机上安装 Python 2.7。虽然它改变了我第一次收到的错误消息的性质,但它并没有做太多事情。

我个人也尝试过做一些研究,看看可能出了什么问题,但我在找到问题的确切答案时遇到了一些困难,因此我想尝试在这里提问。

根据我在网上看到的情况,我认为这是在 Powershell 中调用和运行 python 文件的正确方法。这是我目前正在使用的:

PS C:\Users\nickd\documents\Coding\Comp_Sci_Class\Python\debugger> python my_test.py

这应该运行一个程序来测试调试器是否正在工作。相反,当我尝试使用命令“python”时,我收到以下错误消息:

python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python my_test.py
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
因此,我相信在准备 Python 以在 Windows Powershell 上使用时,我只是缺少一些步骤,但我没有找到一个明确的答案来说明这可能是什么。

有人可以帮助我,并描述我可能需要做什么吗?我知道我所缺少的可能非常简单,如果这是一个愚蠢的问题,我预先道歉。也就是说,如果有人能指出我需要做什么的正确方向,我将非常感激。

谢谢。

最佳答案

Powershell 找不到您安装 python 的位置。如果将 python.exe 所在的文件夹添加到路径中,那么它就可以工作。看到这里https://superuser.com/a/143121

关于python - 第一次尝试从 Powershell 运行 python。我使用的命令是否正确/我需要做什么才能允许使用 Python?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56997205/

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