Install PIP for Python 2 on Ubuntu

Install PIP for Python 2 on Ubuntu

The PyPA recommended tool for installing Python packages.

Install PIP for Python 2

Python 2 is not installed by default on Ubuntu 17.10. But if you do need Python 2 for any specific reason, you can install Python 2 on Ubuntu 17.10.
Run the following command to install Python 2 on Ubuntu 17.10:

$ sudo apt-get install python

Press ‘y’ and press <Enter> to continue the installation. It may take a while to download and install everything depending on your internet connection.

Once Python 2 is installed, you can check the version of Python 2 with the following command:

$ python --version
strong@foreverstrong:~$ python --version
Python 2.7.12
strong@foreverstrong:~$ 

You can see that the installed Python 2 version is 2.7.12.
Now to install PIP for Python 2, run the following command:

$ sudo apt-get install python-pip

Press ‘y’ and press <Enter> to continue the installation. It may take a while to download and install everything depending on your internet connection.
Once the installation is complete, you can check the version of PIP for Python 2 using the following command:

$ pip --version
strong@foreverstrong:~$ pip --version
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
strong@foreverstrong:~$ 

You can see that the version of PIP for Python 2 installed is 18.0 and its installed in /usr/local/lib/python2.7/dist-packages/pip system directory. When we update PIP for Python 2, the installed location will change as it did for PIP for Python 3.

Update PIP for Python 2

To update PIP for Python 2, run the following command:

$ pip install -U pip
strong@foreverstrong:~$ pip install -U pip
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages (18.0)
strong@foreverstrong:~$ 

Now check the version of PIP for Python 2 with the following command:

$ pip --version
strong@foreverstrong:~$ pip --version
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
strong@foreverstrong:~$

You can see that, the version of PIP for Python 2 is 18.0 and just like before the installed location is changed to the current user’s home directory. It verifies that the package update was successful.
So that’s how you install and update PIP for Python 2 on Ubuntu 16.04. Thanks for reading this article.

References

https://linuxhint.com/install-pip-on-ubuntu/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章