How To Install The Latest PIP Version And Ipykernel For Python 2.7

This article will tell you how to install the latest pip version and ipykernel for Python 2.7.

1. Install The Latest PIP Version For Python 2.7.

Python 2.7 does not support PIP anymore, but you can first install Python 3 and then downgrade the pip version to use it in Python 2.7.

First, I get my current pip version in my environment with the command python2 -m pip –version. We can see the current pip version is 6.1.1.

$ python2 -m pip --version
pip 6.1.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (python 2.7)

Then run the command sudo wget https://bootstrap.pypa.io/pip/2.7/get-pip.py in the terminal to download the pip setup file for Python 2.7.

$ sudo wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
--2022-01-27 12:59:56--  https://bootstrap.pypa.io/pip/2.7/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.108.175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.108.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1908226 (1.8M) [text/x-python]
Saving to: ‘get-pip.py’

get-pip.py                    100%[================================================>]   1.82M  1.07MB/s    in 1.7s    

2022-01-27 12:59:58 (1.07 MB/s) - ‘get-pip.py’ saved [1908226/1908226]

If the above command returns the 404 file not found error, you can use a web browser to browse the URL https://bootstrap.pypa.io to get the correct file path. Or you can download the get-pip.py file from my website.

HTTP request sent, awaiting response... 
404 Not Found
2022-01-27 12:59:50 ERROR 404: Not Found.

After that, you can run the command python2 ./get-pip.py to install it.

$ python2 ./get-pip.py 
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 412 kB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 6.1.1
    Uninstalling pip-6.1.1:
      Successfully uninstalled pip-6.1.1
Successfully installed pip-20.3.4

Now you can see the latest pip version for python2 has been installed successfully with the command python2 -m pip –version.

$ python2 -m pip --version
pip 20.3.4 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)

If you want to learn how to run the pip command for python2.7 you can read the article How To Install Python2 (pip2) &amp; Python3 (pip) Successfully On Ubuntu.

2. Install Ipykernel For Python 2.7.

After you upgrade your Python2’s PIP version to the latest version (pip 20.3.4), you can run the command python2 -m pip install –user ipykernel to install the IPython kernel for Python2.7.

$ python2 -m pip install --user ipykernel
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting ipykernel
  Using cached ipykernel-4.10.1-py2-none-any.whl (109 kB)
Requirement already satisfied: ipython>=4.0.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipykernel) (5.10.0)
Collecting jupyter-client
  Using cached jupyter_client-5.3.5-py2.py3-none-any.whl (92 kB)
Requirement already satisfied: traitlets>=4.1.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipykernel) (4.3.3)
Processing /Users/songzhao/Library/Caches/pip/wheels/d8/83/af/e0dc6afbf3a2c51af8d6e3f9fbe790d0c581c2de05bc5d50f5/tornado-5.1.1-cp27-cp27m-macosx_10_6_intel.whl
Requirement already satisfied: pexpect; sys_platform != "win32" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (4.8.0)
Requirement already satisfied: pathlib2; python_version == "2.7" or python_version == "3.3" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (2.3.6)
Requirement already satisfied: pickleshare in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (0.7.5)
Requirement already satisfied: appnope; sys_platform == "darwin" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (0.1.2)
Requirement already satisfied: decorator in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (4.4.2)
Requirement already satisfied: pygments<2.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (2.5.2)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.4 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (1.0.18)
Requirement already satisfied: simplegeneric>0.8 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (0.8.1)
Requirement already satisfied: backports.shutil-get-terminal-size; python_version == "2.7" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ipython>=4.0.0->ipykernel) (1.0.0)
Requirement already satisfied: setuptools>=18.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from ipython>=4.0.0->ipykernel) (41.0.1)
Requirement already satisfied: pyzmq>=13 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from jupyter-client->ipykernel) (19.0.2)
Requirement already satisfied: jupyter-core>=4.6.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from jupyter-client->ipykernel) (4.6.3)
Collecting python-dateutil>=2.1
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Requirement already satisfied: enum34; python_version == "2.7" in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from traitlets>=4.1.0->ipykernel) (1.1.6)
Requirement already satisfied: ipython-genutils in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from traitlets>=4.1.0->ipykernel) (0.2.0)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from traitlets>=4.1.0->ipykernel) (1.12.0)
Collecting backports-abc>=0.4
  Using cached backports_abc-0.5-py2.py3-none-any.whl (5.2 kB)
Collecting futures
  Using cached futures-3.3.0-py2-none-any.whl (16 kB)
Collecting singledispatch
  Using cached singledispatch-3.7.0-py2.py3-none-any.whl (9.2 kB)
Requirement already satisfied: ptyprocess>=0.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pexpect; sys_platform != "win32"->ipython>=4.0.0->ipykernel) (0.7.0)
Requirement already satisfied: scandir; python_version < "3.5" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython>=4.0.0->ipykernel) (1.10.0)
Requirement already satisfied: wcwidth in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from prompt-toolkit<2.0.0,>=1.0.4->ipython>=4.0.0->ipykernel) (0.2.5)
Requirement already satisfied: backports.functools-lru-cache>=1.2.1; python_version < "3.2" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from wcwidth->prompt-toolkit<2.0.0,>=1.0.4->ipython>=4.0.0->ipykernel) (1.6.4)
Installing collected packages: python-dateutil, backports-abc, futures, singledispatch, tornado, jupyter-client, ipykernel
  WARNING: The scripts jupyter-kernel, jupyter-kernelspec and jupyter-run are installed in '/Users/songzhao/Library/Python/2.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
matplotlib 1.3.1 requires nose, which is not installed.
Successfully installed backports-abc-0.5 futures-3.3.0 ipykernel-4.10.1 jupyter-client-5.3.5 python-dateutil-2.8.2 singledispatch-3.7.0 tornado-5.1.1

Then run the command python2 -m ipykernel install –user to create a python2 ipykernel for the current user.

$ python2 -m ipykernel install --user
Installed kernelspec python2 in /Users/songzhao/Library/Jupyter/kernels/python2

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.