Beginner - How to Run/Use Python 3.8.5 on Windows 7, 10 - Set Windows Environment Variables - 2020

Опубликовано: 04 Октябрь 2024
на канале: Suraj Sharma - Full Stack Developer
7,843
66

Are you tired of running 'python.exe' from the python directory and want to run it from anywhere on the command prompt but it does not run at all?

In this video, I will tell how you can execute python from anywhere on the command prompt by updating the environment variables on your Windows System

So let's get started.

I am Suraj Sharma, a full stack web developer having over 6 years of experience in building high-performance web apps.
First Let me go inside the Python folder and show you some important directories, Lib contains all the python's in-build and third-party libraries, Scripts folder contains pip and easy install executable files, so these folders will be added to the environment variable. Next, let's open Run and, type 'sysdm.cpl'. It opens up a System Properties window, I am gonna click on the Advanced Tab, down below you can see an Environment variable button, let's click on it. Environment Variables window pops up. It has two types of variables one is user variables and another one is system variables. I will make changes only to the user variables and not the system variables as it requires Admin rights, some of you might not have the admin rights. same steps could be followed to make changes to the system variables. Let's scroll down to look for Path Variable, here it is, now I am gonna double click to open a pop-up window, now I am gonna update the variable value to add 'C:\python38-32;C:\Python38-32/Scripts' after a semicolon. Now I am gonna add Lib and site-packages folders as a PYTHONPATH variable by clicking on 'new' OK, Ok to apply the changes. I am gonna restart the command prompt. Next, I am gonna run python outside the python directory, it opens up a python interpreter. I will try to run 'pip install virtualenv' to see what happens. as expected it is downloading the package. Next, I will try to run a python script stored in a .py file to print hello world. I already have a hello_world.py file on my desktop. I am changing my current directory to Desktop. running 'python hello_world.py', prints Hello World.

If you find this video useful then please hit the like button. If you haven't subscribed to my channel yet, please do subscribe.


Find me in
Official Website: https://www.surajsharma.net