Fundamentals 5 min read

How to Set Python Environment Variables on Windows in 10 Simple Steps

This guide walks you through why Python may fail to run after installation and provides a detailed, step‑by‑step tutorial—including screenshots—to correctly configure the Windows PATH environment variable so Python commands work from any command prompt.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Set Python Environment Variables on Windows in 10 Simple Steps

Even after installing Python, you might encounter an error when running python from the command line because the environment variable is not set. This article shows how to configure the Python PATH on Windows.

Confirm that Python is installed and locate its installation directory (e.g., C:\Python27 or C:\Python38 ).

Copy the full installation path. You can click the address bar in the folder window to select the path.

Press Ctrl+C to copy the path.

The copied path will look like C:\Python27 . Use the path that matches your installation.

On the desktop, open "My Computer", right‑click and choose "Properties".

In the System window, click "Advanced system settings" on the left.

In the "System Properties" dialog, go to the "Advanced" tab and click the "Environment Variables" button.

In the "Environment Variables" window, select the "Path" variable under System variables and click "Edit".

Append a semicolon and the copied Python path to the end of the variable value (e.g., ;C:\Python27 ), then click OK on all dialogs.

Open a new Command Prompt window and run python again; the interpreter should start, confirming the PATH is set correctly.

After completing these steps, you can use Python from any command line without issues.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonEnvironment Variablespathsetup tutorial
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.