TechBriefly
  • Tech
  • Business
  • Crypto
  • Science
  • Geek
  • How to
  • About
    • About TechBriefly
    • Terms and Conditions
    • Privacy Policy
    • Contact Us
    • Languages
      • 中文 (Chinese)
      • Dansk
      • Deutsch
      • Español
      • English
      • Français
      • Nederlands
      • Italiano
      • 日本语 (Japanese)
      • 한국인 (Korean)
      • Norsk
      • Polski
      • Português
      • Pусский (Russian)
      • Suomalainen
      • Svenska
No Result
View All Result
TechBriefly
Home How to
Running Python files and fixing path errors on Windows

Running Python files and fixing path errors on Windows

Learn how to run a Python file in Command Prompt on Windows, including fixing 'python not recognized' errors and adding Python to PATH.

Emre ÇıtakbyEmre Çıtak
26 December 2025
in How to
Reading Time: 3 mins read
Share on FacebookShare on Twitter

Whether you’re writing your own Python code or running existing scripts on a Windows PC, this guide shows you how to run a Python file from the Windows Command Prompt. It’s a simple process once Python is installed, and you’ll also learn how to fix common errors like “python is not recognized as an internal or external command” or “Python was not found.”

Before you start: Ensure Python is already installed on your Windows PC.

How to run Python scripts from Command Prompt on Windows

Follow these detailed steps to execute your script or fix PATH issues if Python isn’t recognized.

Running your Python script

  • Find the full path of your Python file:
    • Open File Explorer.
    • Navigate to the folder containing your Python file.
    • Right-click the file and select Properties.
    • Copy the path next to Location by highlighting it and pressing Ctrl + C.
  • Open Command Prompt by pressing the Windows key, typing cmd, and selecting the app.
  • Switch to the script’s directory by typing cd followed by a space, then pasting the full path with Ctrl + V and pressing Enter.
  • Type python followed by the filename, such as python script.py, and press Enter to run it.
    • If the filename contains spaces, enclose it in quotes, like python “my script.py”.

Adding Python to the PATH (if needed)

  • Enable viewing of hidden folders in File Explorer:
    • Click the View tab.
    • On Windows 11, select Show > Hidden items.
    • On Windows 10, check the Hidden items box.
  • Locate and copy the Python installation path (typically C:\Users\<yourusername>\AppData\Local\Programs\Python\Python38 or similar):
    • In File Explorer, go to This PC > your hard drive > Users > your username > AppData > Local > Programs > Python > the version folder.
    • Click the address bar at the top to highlight it, then press Ctrl + C.
  • Open System Properties by pressing the Windows key, typing sysdm.cpl, and pressing Enter.
  • Click the Advanced tab.
  • Click Environment Variables.
  • Under User variables, double-click Path.
  • Click New.
  • Paste the Python path with Ctrl + V.
  • Click OK on all open dialogs to save changes.
  • Restart Windows to apply the changes. Now you can run scripts with python <filename>.
Pro tip: Create a dedicated folder for your Python scripts and add it to your PATH as well for quicker access from anywhere in Command Prompt.

After successfully running your first script, test it by creating a simple “Hello, World!” Python file to verify everything works. Experiment with command-line arguments by adding them after the filename, like python script.py arg1 arg2, to pass inputs dynamically.

Explore advanced Command Prompt features for Python development, such as using pip to install packages with pip install numpy. Consider learning virtual environments with venv to manage project dependencies separately and avoid conflicts.

Tags: PythonWindows
ShareTweet
Emre Çıtak

Emre Çıtak

Emre’s love for animals made him a veterinarian, and his passion for technology made him an editor. Making new discoveries in the field of editorial and journalism, Emre enjoys conveying information to a wide audience, which has always been a dream for him.

Related Posts

How to install mods and custom content in The Sims 2

How to install mods and custom content in The Sims 2

26 December 2025
How to boot your PC into Command Prompt for troubleshooting

How to boot your PC into Command Prompt for troubleshooting

26 December 2025
How to delete a virus using Command Prompt

How to delete a virus using Command Prompt

26 December 2025
How to connect a PS4 controller to Steam via USB or Bluetooth

How to connect a PS4 controller to Steam via USB or Bluetooth

24 December 2025

LATEST

How to install mods and custom content in The Sims 2

Running Python files and fixing path errors on Windows

How to boot your PC into Command Prompt for troubleshooting

How to delete a virus using Command Prompt

How to connect a PS4 controller to Steam via USB or Bluetooth

How to connect your phone to Wi-Fi and fix connection issues

Apple begins iPhone 18 series production testing in January

EA investigates AI claims in Battlefield 6 cosmetics

Amazon Alexa+ will book your hotels and salons starting in 2026

OpenAI launches Skills in Codex

TechBriefly

© 2021 TechBriefly is a Linkmedya brand.

  • Tech
  • Business
  • Science
  • Geek
  • How to
  • About
  • Privacy
  • Terms
  • Contact
  • | Network Sites |
  • Digital Report
  • LeaderGamer

Follow Us

No Result
View All Result
  • Tech
  • Business
  • Crypto
  • Science
  • Geek
  • How to
  • About
    • About TechBriefly
    • Terms and Conditions
    • Privacy Policy
    • Contact Us
    • Languages
      • 中文 (Chinese)
      • Dansk
      • Deutsch
      • Español
      • English
      • Français
      • Nederlands
      • Italiano
      • 日本语 (Japanese)
      • 한국인 (Korean)
      • Norsk
      • Polski
      • Português
      • Pусский (Russian)
      • Suomalainen
      • Svenska