-->
2 Methods To Set Python Environment Variable Windows 10 (with a step-by-step YouTube Video Guide)

2 Methods To Set Python Environment Variable Windows 10 (with a step-by-step YouTube Video Guide)

Back to top

Updated by Ashirafu Kibalama on September 17, 2024

Two Methods for Setting Python Environment Variables on Windows 10 (with a step-by-step YouTube Video Guide)







Setting environment variables is essential for any developer working with Python on Windows 10.

Environment variables can help you manage dependencies, configure settings, and streamline your development process.


This blog post will explore two straightforward methods to set Python environment variables on Windows 10.

We'll provide detailed, step-by-step instructions to guide you through the process.


Additionally, we've included a comprehensive YouTube video guide that walks you through each step for those who prefer visual learning.


By the end of this tutorial, you'll have the knowledge and confidence to set up your Python environment variables efficiently.


How to Set Python Environment Variable in Windows 10: 2 Methods (Step-by-Step Guide with YouTube Video)



Watch my YouTube video for The 2 Methods To Set Python Environment Variable Windows 10.





Method 1) Using a Unquie Variable name:


1) Open System Properties:


Press Win + X and select System,





or right-click on This PC and select Properties.    











Click on Advanced System Settings on the left sidebar.




2) Environment Variables:


Remember to click the "Environment Variables" button at the bottom of the System Properties window.



Then, this page appears:




3) Set a New Environment Variable:

In the Environment Variables window, you can add a new variable or modify an existing one.

Click New under the appropriate section (System variables) to set a new Python Environment Variable for your Windows.




Then, this page appears:





Enter the Variable name and Variable value.



For example, to set the PYTHONPATH variable, you might enter PYTHONPATH as the variable name. 


4) Set the path to your Python libraries, i.e. (variable name):






First, type "python" in the Windows search bar, right-click on the Python version installed on your PC, and click "open file location."





Then, this page appears:




Right-click on the Python version and then click open file location as illustrated below:



Then, this page appears:




Then copy the Python libraries path:





Python libraries path example:  C:\Users\User\AppData\Local\Programs\Python\Python312




# Python libraries path example:
C:\Users\User\AppData\Local\Programs\Python\Python312




Go back to step 3)



Then paste the Python libraries path you copied, add a semicolon ";" and again paste the path.

Add these:"\Scripts". C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts

 

Note: Scripts; S must be a Capital letter.



# Python libraries path example:
C:\Users\User\AppData\Local\Programs\Python\Python312;C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts




5) Save Changes:




Then, this page appears:





Access the Python environment variables you have set by double-clicking on the path name, for example, PYTHONPATH. Then, you should see the Python environment variables.




Finally, Click OK to close each window and save your changes.


6) Prove that you have successfully set your Python environment variables:




Enter "python --version" in the command prompt. If it is successful, you will see the Python Version displayed in the command prompt.



Method 2) Editing an Existing Variable path:


1) Open System Properties:


Press Win + X and select System,





or right-click on This PC and select Properties.    











Click on Advanced System Settings on the left sidebar.




2) Environment Variables:


Remember to click the "Environment Variables" button at the bottom of the System Properties window.



Then, this page appears:




3) Edit an existing Environment Variable:


In the Environment Variables window, modify an existing one, for example: "Path".

So Click Path under the appropriate section (System variables) and then click "Edit" to set a new Python Environment Variable for your Windows.






Then, this page appears:






4) Set the path to your Python libraries:






First, type "python" in the Windows search bar, right-click on the Python version installed on your PC, and click "open file location."





Then, this page appears:




Right-click on the Python version and then click open file location as illustrated below:



Then, this page appears:




Then copy the Python libraries path:





Python libraries path example:  C:\Users\User\AppData\Local\Programs\Python\Python312




# Python libraries path example:
C:\Users\User\AppData\Local\Programs\Python\Python312




Go back to step 3)




Then click New:






This appears:









After adding the Path:




Then paste the Python libraries path you copied:

 C:\Users\User\AppData\Local\Programs\Python\Python312

 





Again click New and paste the path.

Add these:"\Scripts". C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts


Note: Scripts; S must be a Capital letter.



# Python libraries path example:
C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts





5) Save Changes:


Finally, Click OK to close each window and save your changes.


6) Prove that you have successfully set your Python environment variables:




Enter "python --version" in the command prompt. If it is successful, you will see the Python Version displayed in the command prompt.



Conclusion

Mastering setting environment variables for Python on Windows 10 is crucial in optimizing your development workflow.


This blog post has provided you with clear, actionable steps to set your Python environment variables.


For those who learn best through visual aids, our step-by-step YouTube video guide is an excellent resource to follow along with.


Implementing these methods will better equip you to handle various Python projects, ensuring a smoother and more productive development experience.


If you have any questions or need further assistance, feel free to leave a comment below or contact us. Happy coding!




Other Posts:

Best 4 Free Exchange Rate APIs With Python Examples (Step-by-Step with YouTube Video)


Build a CV or Resume Generator pdf Flask Python With Source Code (Step-by-Step with YouTube Video) 


3 Ckeditor Alternative: How To Upload An Image Ckeditor Flask Alternative/ Summernote Image Upload Flask Python


A Beginner's Complete Guide: Deploy Flask App with SQLite/ PostgreSQL Database on cPanel/ shared hosting 


5 How to fix: Python was not found Error: Run without arguments to install from the Microsoft Store or disable this shortcut from Settings Manage App Execution Aliases.


6 How to Change or Activate a Virtual Environment in Pycharm Windows/ macOS