Python appears in cmd

Hello

I downloaded Python 310 and then installed it on my system.

Well, everything was okay up to this stage.

After I opened python.exe, it appeared in cmd, not python!

Please guide me what I must to do?

Thank you :slight_smile:

What’s the problem? It’s behaving as it’s intended to.

3 Likes

It’s working fine. If you want IDLE, find it in the start menu.

“python.exe” is a console application. If it doesn’t inherit a console from its parent process, then initialization code in the process automatically allocates a new console. If Python runs without a script, -m module, or -c command, then it simply runs an interactive shell. The console window and shell shown in the screenshot have absolutely nothing to do with the CMD shell.

1 Like

The Python interpreter (python.exe on Windows) is a command line program. You can execute Python code interactively by typing it at the prompt and pressing enter (try print("Hello world!")), and run Python scripts (which you or others may have written) by either typing python followed by the path to the script at the command line, or setting the Python interpreter to be the default file association for .py files (Right click → Open With → Always open with/Always use …`, if its not set already), so you can run them by double-clicking them.

If you want to run Python code, such as a graphical application, in the background without a command prompt window popping up, you can use the pythonw.exe executable instead. However, if something goes wrong, you may not get anything printed to the terminal providing more information on the error. This is probably not what you want as a beginner.

For a simple GUI environment suitable for beginners, IDLE is included with Python and is aimed at this use case. If you’re interested in scientific Python and looking for something easily to use and like the Matlab IDE, you may want to look into Spyder (full disclosure, I’m one of its volunteer core developers) or JupyterLab. There are also many other third party editors and integrated development environments (IDEs).

3 Likes

Before I come to great python website and download V310 I downloaded 10 tutorial videos. The scene of python in the videos had an environment other than cmd:

I didn’t watched the videos carefully but wanted to know python initially.

The teacher turned the scene into cmd (I don’t remember what he did) but added, he doesn’t like cmd environment and prefer to work in the scene that you see in the picture.

After installing python 310 and clicking on the python.exe I expected the same brown scene but cmd appeared instead.

In addition, he used two another pages that you can see in the below pictures that one was sublime text:

Looking at the provided screenshot, that’s because its a terminal running on a Ubuntu Linux system, not native Windows (either through WSL2, a virtual machine or a remote desktop connection). However, you can see Python functions essentially the same, with the standard >>> prompts, just with slightly different aesthetics (a different background color and an increased text size). You can do the same thing with a less primitive terminal emulator than the default, like Windows Terminal or ConEmu, or with the font size/syntax highlighting theme of most IDEs/custom Python consoles. But that’s outside the scope of Python itself.

Again, it would be helpful to clarify what it is that you actually want, and equally importantly, why you want it—are you just looking to change the look of your terminal? Are you looking for a particular type of Python editor, console or IDE? Or do you want to use a whole different operating system? I’m not sure this is the right place for many, if not most of those questions, but we can at least try to suggest somewhere that might be, and if you have more specific questions related to the Python language itself, we can help answer them.

1 Like

I don’t know how to thank you for your kindness that you enlightened me about python itself and its additional facilities.

I think my awkwardly question was because of lacking enough primitive information about python. I realized this fact after I searched other informal websites that described additional complement programs used for python to make it more comfortable for programmers (the programs that you pointed out like IDE).

So I apologize that I took your time and troubled you because of my fault that I didn’t research enough about python before posing any questions. Your guidance was helpful, and now I can research and study the terms you mentioned, and I will go back to the python reference; after I learned them from the different programming sources.

I even wanted to ask the staff to delete this topic after I realized my shortages and insufficient primitive information. Of course, I have learned some commands of python and can work with them, but my problem was that I didn’t know which additional programs (like IDE) were needed for python.
So, I am going to find them and learn more about them.
After learning the cases, I will come back to you to question you and benefit from your knowledge and experience.

Thank you so much :slight_smile:

Sincerely Mans

Mans, I think you will find the Python community to be very willing to help, so do not be concerned about asking questions. Just try to be as clear as possible about what your question is. For example, your question was actually something like “Why did I get a different Python window than the teacher did? Here is the screenshot of my screen and the teacher’s screen.”

Some extra clarification:

  1. A console is a general tool for interacting with a computer by using text commands. The Windows console is used for more than just cmd.

    • cmd (a program whose full name is ‘command.com’ --try typing the long name in the Start Menu) runs in a Windows console. This console is often called a “DOS window” and was the only way to interact with a computer running Microsoft’s Disk Operating System before Windows was created.
    • python.exe is the python language interpreter (plus some other functions) and it also runs in a console.
    • PuTTY is a common program that runs in a console and allows you to connect to a remote computer and send commands to that remote computer and get information and other responses from the remote computer. This screenshot shows the PuTTY console on the left. You can see that it looks very much like the CMD console and the Python console. The screenshot label says that it is from an Ubuntu system.
  2. Every different type of console will have a “signature” at the line where it is waiting for you to type a command.

    • A Python command line starts with ‘>>>’
    • A CMD command line starts with a letter showing what hard drive you’re working with and where you are on the drive [screenshot]. It sounds like you are at least a little familiar with the DOS console and you have probably seen:
C:\>_
  • Most Linux consoles use $ to indicate the command line, as you can see at the bottom of this screenshot. Some use the character #.
  1. Learn the command line “prompt” character for the console(s) you use and you will always know what environment you are in.
1 Like

The CMD shell was developed for OS/2 in the late 1980s, in a development partnership between Microsoft and IBM. It is not the same as the COMMAND shell from DOS systems (e.g. MS-DOS, PC-DOS) [1], but it was designed to have a similar interface and commands and to be compatible with DOS batch scripts. In the early 1990s, CMD was ported to the 32-bit Windows API as a console application, and it has been the default shell (i.e. %ComSpec% command interpreter) in Windows NT systems from 1993 to the present day [2].

The terms “DOS window” and “DOS box” apply only to Windows 3.x and Windows 9x. These systems use the CPU’s virtual 8086 mode to run 16-bit DOS applications in a VM, with the DOS keyboard and display redirected to a window. The command-line shell in these systems is MS-DOS COMMAND.COM.

Starting with Windows XP (2001), consumer versions of Windows are based on NT. Prior to Windows 7 (2008), NT systems host each console session using threads in the session server process, csrss.exe, which runs in the SYSTEM security context. In Windows 7+, each console session is hosted in a “conhost.exe” process (or “openconsole.exe”), which runs in the same security context as the process that allocates the console session (e.g. cmd.exe, python.exe, etc).


[1] DOS is a single-user operating system that was popular on personal computers in the 1980s and 1990s. From a programmer’s perspective, DOS is a set of system calls available via x86 software interrupt 0x21, implemented in MS-DOS by “IO.SYS” and “MSDOS.SYS”. From a user’s perspective, DOS is the “COMMAND.COM” shell and various utility programs (e.g. “FIND.EXE”, “XCOPY.EXE”, “FORMAT.COM”). Originally DOS was limited to 16-bit x86 instructions, 1 MiB of RAM, single tasking, and short filenames (8 characters plus a 3 character extension, e.g. “FILENAME.TXT”). Over time it was extended to support 32-bit protected mode (DPMI), expanded/extended memory (EMS/XMS), multitasking (e.g. DESQview), and long filenames. AFAIK, it never supported multiple users or security (i.e. accounts, rights, privileges, and objects/files secured by ACLs).

[2] NT was developed from 1989 to 1993 by a small team (consisting of mostly VMS developers that Microsoft poached from DEC), including David Cutler (kernel, team leader), Lou Perazzoli (memory manager), Mark Lucovsky (process manager), Steve Wood (object manager), Darryl Havens (I/O manager), Tom Miller (cache manager), and Gary Kimura (filesystems). Originally it was called “NT OS/2”, with OS/2 as the primary subsystem and user interface, plus a POSIX subsystem for command-line Unix applications (extended by Interix in 1996, but removed nowadays in favor of the Linux subsystem, WSL). However, Windows 3.0 was so popular and acclaimed when it was released in 1990 that by 1991 Microsoft began developing a 32-bit Windows API (Win32) and made Windows the primary NT subsystem. The first released version was Windows NT 3.1 (1993). It was named to align with Windows 3.1 (1992), the consumer version of Windows that was based on DOS (though heavily extended by a 32-bit virtual machine manager and 32-bit VxD drivers). The next consumer version, Windows 95, introduced the Explorer shell with the start button and task bar, which was subsequently integrated into Windows NT 4.0 (1996). The last split release was Windows Me (based on VMM/DOS) and Windows 2000 (based on NT). The first version of NT marketed for popular consumption was Windows XP (2001).

3 Likes

Thank you so much, Mr. Parker

The nice summary explanations enlightened me on what to choose and what to do to arrive at the vast python world, and took me out of the confusion . Of course, I’m at the beginning point of the way, and there is a long distance to the place I become a programmer in python, nevertheless, I will try to reach the point gradually.

Your guidance was like a road map so that I find my initial way in this vast land.

Thank you again :slight_smile:

1 Like

The CMD shell…is not the same as the COMMAND shell from DOS systems[.]

Hah! I was wondering if someone would bring this up. I omitted this level of detail since Mans said that he is a beginner with Python. [Revised wording; original term here].

Even Windows has both CMD and COMMAND, which are extremely similar but not the same. (At least Windows XP or Win7 did. I haven’t run Command.com in many years since CMD has all of the functions that I typically need and is so much easier to type.)

[ Slight Correction: ] cmd.exe is the more comprehensive of the two shell programs. As I said, it has been a while; the details of why I switched are dim and a bit superfluous now, particularly since according to this comparison article command.com sends its non-native/unrecognized commands to cmd.exe. Some readers might be interested to note the following quote from the article.

COMMAND.COM and CMD.EXE have almost identical features

DOS applications such as COMMAND are automatically executed in 32-bit Windows NT systems using the Virtual DOS Machine (ntvdm.exe). It wasn’t ported to 64-bit Windows, but there’s still DOSBox. Either way, a DOS app is running in an emulator.

CMD is similar to COMMAND, in terms of the names of some its commands and basic behavior. But they aren’t extremely similar. CMD is a Windows console application that uses the Win32 Unicode API (e.g. CreateProcessW(), ReadConsoleW()). COMMAND is a 16-bit DOS application from the early 80s, originally written in x86 assembly and based on DOS INT 0x21 system calls.

For example, in COMMAND the CHCP internal command wraps DOS system call 0x66 (102). This system call gets and sets the global code page and country locale data for the DOS kernel and all devices that support code page switching. It’s implemented by the NLSFUNC resident (TSR) application, which has to be set up and installed beforehand (e.g. set the location of country data, which defaults to “COUNTRY.SYS”). In Windows CMD, on the other hand, there’s an external “chcp.com” console application, which calls the Windows API functions GetConsoleCP(), SetConsoleCP(), and SetConsoleOutputCP(). It has nothing to do with setting the current locale (or UI language) used by the system and applications, which typically use the locale and preferred UI language of the current user, as configured in “HKCU\Control Panel\International”.

1 Like

This is a topic started by a complete beginner to Python. We should keep the technical detail VERY LIGHT.

Thanks for this helpful tip, @CAM-Gerlach! Definitely not beginner level, but it handles a situation I have with a commercial application.


This is the IDLE version of Python.
The IDLE version looks like Notepad and it seems to be a colorful Notepad.