[英]Trying to run Python program from command prompt
Path must be messed up and I can't fix it.路径必须搞砸了,我无法修复它。
In the command prompt I am trying to open and run a python program that I made in IDLE.在命令提示符下,我试图打开并运行我在 IDLE 中制作的 python 程序。 I am running Python 3.8.5.
我正在运行 Python 3.8.5。 According to Automate the Boring Stuff, I should just be able to do:
根据 Automate the Boring Stuff,我应该能够做到:
py birthdays.py
But when I do that I get:但是当我这样做时,我得到:
C:\Users\name\AppData\Local\Programs\Python\Python38-32\python.exe: can't open file 'birtdays.py': [Errno 2] No such file or directory
All of my scripts are located in: C:\Users\henri\AppData\Local\Programs\Python\Python38-32
.我所有的脚本都位于:
C:\Users\henri\AppData\Local\Programs\Python\Python38-32
。
The only thing that I could think of is that it is going one step too far and searching in python.exe
instead of just Python38-32
.我唯一能想到的是,它走得太远了,在
python.exe
而不仅仅是Python38-32
中搜索。 But Ii'm not even sure it works like that.但我什至不确定它是那样工作的。
I tried to add the exact path using:我尝试使用以下方法添加确切路径:
set PATH=%PATH%;C:\Users\name\AppData\Local\Programs\Python\Python38-32
But when I do this and press enter nothing happens.但是当我这样做并按下回车键时,什么也没有发生。
when I want to use CMD to run python scripts, I just use当我想使用 CMD 运行 python 脚本时,我只是使用
cd\
to back the main root of drive C. then use备份驱动器 C 的主根。然后使用
cd folderAddress
for several time until to reach the exact scrip containing folder.几次,直到到达包含文件夹的确切脚本。 Finally, I type
最后,我输入
python scriptName.py
In your command prompt type python.The output should be python 3.** (depending on your python version).在您的命令提示符中键入 python。output 应该是 python 3.**(取决于您的 python 版本)。
If you see the python version it's working fine.如果您看到 python 版本,则它工作正常。 In command prompt navigate to the folder that you have your python file using cmd command.
在命令提示符下,使用cmd命令导航到您拥有 python 文件的文件夹。 then type
然后输入
python birtdays.py
python 生日.py
Don't forget the space after python.不要忘记 python 之后的空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.