赞
踩
The PyPA recommended tool for installing Python packages.
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.
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.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。