Python is known to be a Data Science programming language that effectively and simply solves algorithmic problems or Python is used to develop web applications. Python is a universal programming language. Python eases the execution of code because of its built-in library functions in object-oriented programming.
Python has a large collection of library and it keeps on upgrading. Due to this, there are many versions of Python and Pythonists sometimes find it difficult to make a particular Python version default. Through this write-up, let us understand how we can make Python 3 version default in Windows operating system.
Table of Contents
Step 1: Getting started from command-line
To check the Python version installed in your computer, you need to execute the following command command-line prompt:
You will be able to check the latest version of Python you have installed:
Step 2: Downloading relevant Python version
If in case, Python 3 is not installed in your system, try installing it from Python.org or follow this link https://www.python.org/downloads/windows/
Scroll down and download the executable file of the size of your windows (32-bit or 64-bit).
You only need to double click on the executable file and install it.
Step 3: Adding Python3 to the windows environment variable path
Now, when you have completed the installation of Python 3 in your system, let us see how we can add Python 3 version to the path. The default path will be:
Now, the above path is not convenient as AppData is a hidden folder that may cause problems with a few of the Python modules such as Jupyter. Therefore, move it to C drive (C:/)
Now, change the name of its executable to python3.exe.
Done? Now, Locate Environment Variables in your system. This will be done by right-clicking on “This PC” option in your computer and click on the Properties option. After doing this, click on Advanced System Settings under the Properties option.
Once you have done this, a pop-up will appear on the screen that will be displaying various options out of which you have to click on Environment Variable Option. The Environment Variables will open up and you can view all the system variables present there.
After clicking on the Path option make sure to put the Scripts and Program Files path of different Python versions that you currently want to use and work in, and where you want to store all your necessary packages should be put first followed by others. Simply, click on the Browse button and select the path of the Script folder and the Python3 itself.
Note: Remove any other Python Version available in the System variables, for example, Python2. Select its path and click on the Delete button.
Press the OK button to save the changes in the Windows’ Environmental Variables.Now, edit the environment variables to add new Python 3 to the path.
Add the two new variables as follow:
Now, click on OK button.
Its time to open the command prompt:
When you type “python3” in the cmd, you should see the Python 3 interpreter opening:
Step 4: Upgrade pip to be able to install Python modules
If you are trying to run pip3 for this new python install, you could run into the following problem:
“Fatal error in launcher: Unable to create process …”
Don’t worry! You can correct that by entering:
python3 -m install --upgrade pip
You pip will then will be upgraded and you will become able to install again Python modules.
Once this is done, restart your Command prompt and again type python –version. Now you will find the desired version there on the system and ready to be usable by the coder.
If you are facing any problem, leave a comment below.