![best way to download python 2.7 best way to download python 2.7](https://www.codingem.com/wp-content/uploads/2021/09/download-python.png)
- #Best way to download python 2.7 how to#
- #Best way to download python 2.7 install#
- #Best way to download python 2.7 manual#
- #Best way to download python 2.7 code#
#Best way to download python 2.7 code#
If we were writing code using Python 3, we would specify Python 3 when running the program. Error when using Python3 to execute Python2 code If we used Python 3 to execute the code below, we would get an error, as shown below. python2 Example.py Execute the Python 2 code For example, the python file is called Example.py. Step 4) To execute your code using Python 2, you will need to specify the version manually. Now write your Python 2 or Python 3 code.įor example, below is a Python 2 code to print the sentence “ Hello, This .“ Python2 Code Step 3) In this post, we currently have Python 2 and Python 3 available. ls /usr/bin/python* Check all the installed Python versions in the bin directory Step 2) Check the Python versions present in your system by running the command below.
#Best way to download python 2.7 install#
Step 1) Install Python 2 with the command below.
#Best way to download python 2.7 manual#
This other method, we would refer to it as the manual way since we won’t perform any configurations.
![best way to download python 2.7 best way to download python 2.7](https://tecadmin.net/wp-content/uploads/2016/07/python-install-4.png)
Method 2: Old-school way without configuration In this case, we would choose option 2 to use Python 3.
![best way to download python 2.7 best way to download python 2.7](https://miro.medium.com/max/1384/1*zyCxzuz77ybBxtiQ5NxWEA.png)
To switch to another Python version, all you need to do is execute the command on Step 4 and select the other option. python -version Check the currently running Python Version Step 5) Now, let’s check the Python version currently running on our system. In this post, we want to use Python 2 therefore, we will enter option 1. On the prompt that appears on the Terminal, enter 1 or 2 to make your selection. $ sudo update-alternatives -config python Confirm the Python Alternatives set Step 4) We need to confirm the Python alternatives set and whether they are in use.Įxecute the command below again. $ sudo update-alternatives -install /usr/bin/python python /usr/bin/python3 2 Configure Python Alternatives $ sudo update-alternatives -install /usr/bin/python python /usr/bin/python2 1 From the image in Step 2 above, we saw that I have Python 2.7 and Python 3.8 present on my system.Įxecute the commands below on the Terminal. Step 3) Now, we will configure two Python alternatives. sudo update-alternatives -list python Check for any Python alternatives configured on the systemįrom the image above, we see that there are no Python alternatives configured. Step 2) Once we have listed all the versions present on the system, we need to check whether there are any Python-alternatives configured.Įxecute the command below on the Terminal. In such situations, the –version command won’t be useful as it only lists the currently configured version.Įxecute the commands below on the Terminal. That is because we can have variations in Python 3. To do so, we will need to check the /bin directory. Step 1) Check all the available Python versions in your system.
#Best way to download python 2.7 how to#
How to switch between Python 2 and 3 versions on Ubuntu 20.04 Method 1: My recommended way by configuring Now, let’s jump on to one of the important parts of this tutorial of how to configure Python and switch between the two versions – Python 2 and Python 3. Python3 -version Check the python version installedįrom the image above, we can see we are running Python 2.7 and Python 3.8. Step 2) Once the installation complete, you can check the Python 2 version using the “–version” command. $ sudo apt install python-minimal Install Python2 in Ubuntu 20.04 LTS You will be required to enter your root password. Step 1) Launch the Terminal and type any of the commands below.