3

What is the difference between the regular terminal on my computer and the terminal I get when I open a new project in PyCharm?

Will your answer change if it's a Conda interpreter instead of regular Python interpreter in the new project?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Moran Reznik
  • 1,201
  • 2
  • 11
  • 28
  • I think PyCharm uses the default system terminal so it should be the same as normal. Note that the terminal where code execution is displayed is different as it a `subprocess` instance running the python code. – NotAName Aug 03 '21 at 07:26
  • Sorry for the close vote, I misread. Reopened. – timgeb Aug 03 '21 at 07:27

2 Answers2

4

What is the difference between the regular terminal on my computer and the terminal I get when I open a new project in PyCharm?

The difference is the Terminal emulator inside PyCharm interfaces with an OS process using an API. The OS shell process is launched and owned by the PyCharm process instead of being launched directly by the user on the OS. (For a disambiguation of the sometimes interchangeable terms, see also What is the difference between Terminal, Console, Shell, and Command Line?).

PyCharm is mainly implemented on Java (integrating some functionalities in other languages, like the Python debugger in CPython). The Terminal is a plugin in Java that integrates with the IDE. As shown in the following screenshot from File > Settings > Plugins > Terminal.

enter image description here

The Terminal emulator plugin in PyCharm can integrate several shells (e.g. "Windows PowerShell, Command Prompt cmd.exe, sh, bash, zsh, csh, and so on"). The following example shows several cmd.exe terminal tabs open inside the PyCharm Terminal emulator Plugin.

enter image description here

On Windows if you open Task manager after launching the cmd.exe terminals inside PyCharm what you'll see, as shown in the next screenshot, are cmd.exe terminals launched by the PyCharm process. At the bottom of the screenshot a user launched native console process on the OS is also shown.

enter image description here

Each terminal process is independent, using Command prompt gives you 2 processes for each terminal one Console Window Host process and one Windows Command Processor process. But more notably you also have a winpty-agent.exe process which corresponds to launching winpty. So this raises the question, what is winpty and how does it work?

Addressing the last question wold require a complex OS level answer, but it would still not be enough because you would have to ask and answer the same question for each different combination of terminal (zsh, cmd, bash, etc) on each kind of OS (Linux, Windows, etc). The PyCharm Terminal emulator plugin abstracts these details and the user can assume the chosen OS terminal functionalities and properties are preserved by the PyCharm Terminal emulator plugin. Some configuration of the Terminal is possible inside the IDE by going to File > Settings > Tools > Terminal.

enter image description here

Will your answer change if it's a Conda interpreter instead of regular Python interpreter?

No. Because the interpreters are processes than can be launched inside a terminal. So this latter question is independent of the former.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
0

You can inspect/configure the shell that's used within Pycharm under

Settings → Tools → Terminal → Application Settings → Shell Path

Per default, this should be your standard system shell.

timgeb
  • 76,762
  • 20
  • 123
  • 145