Open In App

How to use CMD for Python in Windows 10?

Last Updated : 11 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Using the Command Prompt (CMD) is an effective way to interact with Python on your Windows 10 machine. Whether you're writing scripts, testing code, or running programs, mastering CMD for Python in Windows 10 is crucial.

This article will guide you on how to run Python in CMD, execute scripts, and troubleshoot common issues. By mastering these CMD commands, you'll improve your coding efficiency and streamline your development process.

Detailed Steps to Use CMD for Python in Windows 10

By the end of this tutorial, you'll be proficient in using CMD for your Python projects, enhancing your development efficiency and control.

Step 1: Check Python Installation

  • For setting up Python on CMD, we must check whether Python is installed on your machine or not. For doing this, go to the Windows search bar and search for Python. If you find Python in the result, then you are good to go.
You can see Python3 is installed on my computer

Note: If Python is not installed on your computer, then it can be installed with How to Install Python on Windows 

Step 2: Check Python Setup

  • Now check whether Python is already set up in Command Prompt or not. For doing this just open cmd and type python. If you see any Python version then it is already setup. 

You can see after typing Python nothing happened. So, python is not set up on cmd yet.

Step 3: Open IDLE Python File Location

  • Now open the Windows search bar and search for "idle". Without opening the app click on "Open file location". If you didn't get the option right click on the app and you will get it.

Now a file location will be opened on Windows Explorer.

Step 4: Open IDLE File Location

  • Now right-click on "IDLE" and click on "open file location"
Click on "Open file location"
  • After opening the file location copy the path.
Copy the location 

Step 5: Search Environment variables

  • Now go to the Windows search bar and search for "Environment variables" and open it.
Open this  
  • After opening the menu click on "Environment Variables"
Click on the "Environment Variables"
  • Now double-click on the "path" in the "System Variables"
  • In the "Edit System Variable" menu click on "new", then paste the file location you copied and click ok.
  • Now close the Environment menus by clicking ok and congratulations, we have set up the Command Prompt for Python.

Step 6: Open CMD

  • Now check whether it works. Open Command Prompt and type "python" and hit enter. You will see a python version and now you can run your program there.

Conclusion

Learning how to use CMD for Python in Windows 10 is a valuable skill that allows you to run and test your Python code quickly and efficiently. By understanding how to set up and navigate the Python command line in Windows 10, you can streamline your workflow and focus more on writing code rather than dealing with setup issues. Whether you're a beginner or an experienced developer, these skills will make your Python development process smoother and more effective.


Next Article
Practice Tags :

Similar Reads