简体   繁体   English

尝试从命令提示符运行 Python 程序

[英]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.

相关问题 Python,尝试从命令提示符运行程序 - Python, trying to run a program from the command prompt 如何从Windows命令提示符运行远程Python程序 - How to run a remote Python program from Windows command prompt 尝试从 Powershell 运行 python 程序时,Powershell 提示返回提示但不返回 Python 输出 - Powershell prompt returning prompt but not Python output when trying to run a python program from Powershell (Python) 尝试运行包含变量的命令提示符命令 - (Python) Trying to run a command prompt command containing a variable 如何从bash shell提示符中将sentiance作为命令行参数运行python程序 - How to run python program with a sentance as a command line arguments from bash shell prompt 如何从 windows 命令提示符在虚拟环境中运行 python 程序? - How do I run a python program in a virtual environment from windows command prompt? 无法通过Windows命令提示符运行简单的Python程序 - Cant make simple Python program run through Windows command prompt 如何在 Windows 7 的命令提示符中运行 Python 程序? - How do I run a Python program in the Command Prompt in Windows 7? 如何从命令提示符运行 Pygame Zero 程序? - How can I run a Pygame Zero program from the Command Prompt? 从Python程序响应git命令行提示符 - Respond to git command line prompt from Python program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM