How to Launch Python Files Using Windows Command Prompt

Find Python file path

How to Launch Python Files Using Windows Command Prompt Picture 1

Go to the directory containing the Python file. Find the Python file you want to open on Command Prompt.

If you already know the directory path of the Python file you want to open, you can open the file on Command Prompt immediately.

How to Launch Python Files Using Windows Command Prompt Picture 2

Select the Python file. Click on the Python file for which you want to view the directory path.

How to Launch Python Files Using Windows Command Prompt Picture 3

Right click on the Python file. A menu will drop down.

How to Launch Python Files Using Windows Command Prompt Picture 4

Click the Properties option in the drop-down menu. The Properties window will open.

How to Launch Python Files Using Windows Command Prompt Picture 5

Record the "Location" value. The directory address (or "path") to the right of the "Location" heading is the information you need to enter into the Command Prompt to switch to the directory containing the Python file.

You can copy a location by highlighting the information (click and drag over the "Location" value) and then press Ctrl+ C.

Launch the Python file

How to Launch Python Files Using Windows Command Prompt Picture 6

Open Start . Click the Windows icon in the lower left corner of the screen. The Start menu will pop up.

How to Launch Python Files Using Windows Command Prompt Picture 7

Find Command Prompt. Type cmdto find Command Prompt.

How to Launch Python Files Using Windows Command Prompt Picture 8

Click the Command Prompt program that appears at the top of the Start menu. Command Prompt will open.

How to Launch Python Files Using Windows Command Prompt Picture 9

Switch to the directory containing the Python file. Enter the command cdand a space, then enter the "Location" address of the Python file and press ↵ Enter.

For example, to open a Python file located in the "Files" folder on the Desktop, you need to enter cd desktop/Fileshere.

If you copied the file path, enter it cdwith a space and press Ctrl+ Vto paste the path.

How to Launch Python Files Using Windows Command Prompt Picture 10

Enter the command "python" along with the file name to open. Enter the command python file.py, which replaces file with the Python filename.

For example, if the Python file is named "script" then you need to enter it python script.pyhere.

If the Python file has more than one space in the name, we will enclose the name and file extension between quotation marks (e.g., python "my script.py").

How to Launch Python Files Using Windows Command Prompt Picture 11

Press ↵ Enter. The command will be executed and open the Python file in the Python program available on the computer.

If an error 'python' is not recognized as an internal or external commandappears after pressing Enter , you need to add Python to the PATH list and try again.

Add Python to the PATH list

How to Launch Python Files Using Windows Command Prompt Picture 12

Show hidden folders. Since one of the folders containing the Python installation directory is most likely hidden, we need to unhide them before continuing:

Open File Explorer.

Click the View tab.

Check the "Hidden items" box.

How to Launch Python Files Using Windows Command Prompt Picture 13

Go to the Python directory. In some cases, the path to Python will be "C:Python27"; however, if you installed the latest version of Python using the default settings, the program will be in a hidden folder. You can copy the appropriate file path by:

Click This PC on the left side of the File Explorer window.

Double-click the hard drive located in the "Devices and drives" section.

Scroll down and double-click the "Users" folder.

Double-click the folder with your username.

Scroll down and double-click "AppData".

Double click "Local".

Scroll down and double-click "Programs".

Double-click the "Python" folder.

Double-click the Python folder along with the appropriate version number (for example, "Python36").

How to Launch Python Files Using Windows Command Prompt Picture 14

Copy the path to the Python folder. Click the address bar at the top of the File Explorer window to highlight the content, then press Ctrl+ Cto copy the address.

How to Launch Python Files Using Windows Command Prompt Picture 15

Open the Power User menu. To proceed, right-click the Start icon . A menu will pop up.

You can also press ⊞ Win+ Xto open the Power User pop-up menu.

How to Launch Python Files Using Windows Command Prompt Picture 16

Click the System option . It's in the pop-up menu. A new window will open.

How to Launch Python Files Using Windows Command Prompt Picture 17

Click System info . This link is in the upper right corner of the window. The System Information window will open.

How to Launch Python Files Using Windows Command Prompt Picture 18

Click the Advanced system settings link . This link is in the upper left of the System Information window. At this point, another window will pop up.

How to Launch Python Files Using Windows Command Prompt Picture 19

Click Environment Variables… (Environment variables). This option is in the lower right corner of the pop-up window.

How to Launch Python Files Using Windows Command Prompt Picture 20

Find the "Path" heading in the "User variables" table. This pane is at the top of the Environment Variables window.

You may need to scroll your mouse pointer up or down on the "User variables" box to find the "Path" variable.

How to Launch Python Files Using Windows Command Prompt Picture 21

Double-click the "Path" heading. A window will pop up.

How to Launch Python Files Using Windows Command Prompt Picture 22

Click the New option . It's on the right side of the window. A text field will appear in the middle of the window.

How to Launch Python Files Using Windows Command Prompt Picture 23

Paste the path you copied earlier. Press Ctrl+ Vto paste the content. The path you copied will appear in the text field in the middle of the window.

How to Launch Python Files Using Windows Command Prompt Picture 24

Click OK on the three open windows. The system will save the changes and close the three windows "Path", "Environmental Variables" and "System Properties".

4 ★ | 1 Vote

May be interested

  • 10 useful commands in Windows you should know10 useful commands in Windows you should know
    command prompt is used to execute batch files, perform tasks quickly, help you troubleshoot and solve some windows problems when the system crashes. however, not all commands in windows are useful and must be done regularly. with the 10 command lines in the following article it is very useful even if you are not an administrator.
  • Tips to burn ISO file from Command Prompt on Windows 10Tips to burn ISO file from Command Prompt on Windows 10
    windows 10 also allows users to burn iso files without having to use any 3rd party software or tools. actually burning iso files doesn't need to use the first integrated third tool on windows 7. all you need is a blank cd / dvd and iso file.
  • 6 Cool Tricks You Can Do in Windows Command Prompt6 Cool Tricks You Can Do in Windows Command Prompt
    command prompt has a ton of capabilities, and many people doubt they know what a few lines of code can do. next time you're bored with your pc, try these cool command prompt tricks for yourself.
  • How to Customize the Font in Windows Command PromptHow to Customize the Font in Windows Command Prompt
    many people work regularly with the windows command prompt. one of the main problems users encounter, however, is the difficulty of achieving the same look every time one works with the command prompt interface. this article is intended to...
  • 6 Best Command Prompt Alternatives for Windows6 Best Command Prompt Alternatives for Windows
    do you find the command prompt a bit complicated and feel you need a tool that is easier to use? this is where other terminal emulators come into play!
  • How to Make Command Prompt Appear at SchoolHow to Make Command Prompt Appear at School
    this wikihow teaches you how to access command prompt on a windows 10 school computer. although you may be able to open command prompt if only the file path to command prompt is blocked, there is no way to bypass an administrator lock on...
  • How to Create and Delete Files and Directories from Windows Command PromptHow to Create and Delete Files and Directories from Windows Command Prompt
    this wikihow teaches you how to use the windows command prompt to create and delete files and folders (also known as directories). the files you create at the prompt can be modified and managed with windows apps, including file manager and...
  • Windows promptWindows prompt
    the prompt command changes the command prompt cmd.exe file.
  • How to Create a Custom Windows Command PromptHow to Create a Custom Windows Command Prompt
    the windows command prompt (located at c:windowssystem32cmd.exe) is a useful tool to perform various administrative tasks. the prompt is a string of characters (special and non special) that are displayed whenever the command prompt is...
  • How to Open Folders in CMDHow to Open Folders in CMD
    do you need to access something from the command prompt or the windows command prompt? although it looks classic, this program is really easy to use if you know some basic commands. today's tipsmake will show you how to use the 'cd' command to open a folder in windows command prompt. besides, you will also know more great tips to instantly open command prompt in any folder on windows file explorer.