简体   繁体   English

在终端和IDE中运行python有什么区别?

[英]What is the difference between running python in terminal and in IDE?

I'm new in Python. 我是Python新手。 I'm using Windows 7. 我正在使用Windows 7。

When I install pip on my computer, I need to use the installing program: get-pip.py. 在计算机上安装pip时,需要使用安装程序:get-pip.py。

I found 3 ways to run this .py file: 我发现了三种方法来运行此.py文件:

  1. In cmd, type "python get-pip.py" 在cmd中,输入“ python get-pip.py”
  2. Open it with IDLE and F5 用IDLE和F5打开
  3. Double click get-pip.py 双击get-pip.py

I have two questions: 我有两个问题:

  1. The only way can install it is "1. In cmd, type "python get-pip.py". I wonder what's the difference between 1 2 and 3? 可以安装的唯一方法是“ 1.在cmd中,键入“ python get-pip.py”。我想知道1 2和3之间有什么区别?

  2. Usually, when I double click .py file, it is usually opened by idle(default). 通常,当我双击.py文件时,通常会被闲置打开(默认)。 But this time, when I double click get-pip.py, it begins running as if a .exe file. 但是这一次,当我双击get-pip.py时,它开始像.exe文件一样开始运行。 Why? 为什么?

Thank you. 谢谢。

Answer to question 1. If you run python from within a command window (cmd) you will be able to see the output if any. 对问题1的回答。如果从命令窗口(cmd)中运行python,则将看到输出(如果有)。 As opposed to double clicking it which will run the program and close it unless the program is supposed to do otherwise. 相对于双击它会运行程序并关闭它,除非该程序本来应该这样做。 And Idle is mimicking the open command window. 空闲模拟打开的命令窗口。

One thing to watch out for is having 2 python interpreters on the system. 要注意的一件事是系统上有2个python解释器。 If you are just starting out I would avoid installing a 2nd one. 如果您只是刚开始,我会避免安装第二个。 Removing old python interpreters is as easy as removing the folder they are in. You said it "runs differently" which makes me think this is a concern. 删除旧的python解释器就像删除它们所在的文件夹一样容易。您说它“以不同的方式运行”,这使我认为这是一个问题。

Answer to question 2 You can change what program uses the file. 对问题2的答案您可以更改使用该文件的程序。 You can have idle read it, or the python interpreter run it. 您可以空闲读取它,或由python解释器运行它。 check out http://www.thewindowsclub.com/change-file-associations-windows for info on how to change that behavior. 请访问http://www.thewindowsclub.com/change-file-associations-windows,以获取有关如何更改此行为的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 终端中的“py”和“python”有什么区别? - What is the difference between 'py' and 'python' in the terminal? 在交互式shell和Linux终端(ubuntu 13)中运行python脚本有什么区别? - What's the difference between running python script in interactive shell and in Terminal of Linux(ubuntu 13)? VS code IDE 中的 jedi 和 python 语言服务器有什么区别? - What is the difference between jedi and python language server in VS code IDE? 在终端中使用 Python 3 和 pip3 安装软件包有什么区别? - What is the difference between installing packages with Python 3 and pip3 in terminal? VS Code 中的 Python 终端与 bash 终端有什么区别? - What is the difference between a Python terminal vs. a bash terminal in VS Code? 在 Raspberry 上从终端运行 Python 脚本失败,但在 IDE 中运行很好 - Running Python Script from Terminal on Raspberry fails but running in IDE is fine 使用服务器上运行的python脚本和存储过程有什么区别? - What is the difference between using a python script running on server and a stored procedure? 运行多个python脚本和多处理之间有什么区别 - What is the difference between running multiple python scripts and multiprocessing 在 IDLE 和终端中编码有什么区别? - What's the difference between coding in the IDLE and the terminal? python 中 // 和 //= 有什么区别? - What is the difference between // and //= in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM