当前位置:   article > 正文

Install PIP for Python 2 on Ubuntu

install pip for python 2

Install PIP for Python 2 on Ubuntu

The PyPA recommended tool for installing Python packages.

1. 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
  • 1

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
  • 1
strong@foreverstrong:~$ python --version
Python 2.7.12
strong@foreverstrong:~$ 
  • 1
  • 2
  • 3

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
  • 1

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
  • 1
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:~$ 
  • 1
  • 2
  • 3
  • 4
  • 5

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.

2. Update PIP for Python 2

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

$ pip install -U pip
  • 1
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:~$ 
  • 1
  • 2
  • 3
  • 4
  • 5

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

$ pip --version
  • 1
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:~$
  • 1
  • 2
  • 3
  • 4
  • 5

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/

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号