pip is an incredibly handy package manager for Python. As of Python 3.4, it is included with default distributions of Python.1 Once you are used to using it, you will miss having it when stuck working with older versions.
Fortunately, pip can be installed to pre-3.4 versions of Python in a few simple steps. Oddly enough, though the process is simple, a complete solution wasn't easily available (via very quick Googling, anyway) so I'll write the process here.
Assumptions
For the steps below, assume a Windows platform with the following structure:
C:\ Python32\ python32.exe Python33\ python33.exe Python34\ python.exe Scripts\ pip.exe pip3.exe pip3.4.exe
The above tree is incomplete of course; only relevant portions are included.
Each C:\PythonXX
directory is on the system PATH, so the older version executables have been renamed to not conflict with each other, e.g. Python32\python.exe
was renamed Python32\python32.exe
. In this setup, executing python
is intended to always default to the latest version installed.
Given this setup, assume you want to install pip to Python 3.3.
Steps
-
Download
get_pip.py
from https://pip.pypa.io/en/latest/installing.html -
Navigate to the directory of
get_pip.py
and runpython33 get_pip.py
. The version of Python used to run the script must be the one to which you want pip installed. -
get_pip
should successfully execute (it may install e.g. setuptools as well, but this happens automatically), and have placedpip.exe
,pip3.3.exe
, and some more files inC:\Python33\Scripts
. Note the versioned executable, in this casepip3.3.exe
, is helpful to specify for which version of Python you want to run pip. -
Add
C:\Python33\Scripts\;
to the system PATH (don't forget the trailing semicolon). There are plenty of guides out there for how to do this. Here is one for Windows 7/8. -
There may now be multiple versions of
pip.exe
on the path, thus executingpip
may not default to the version of Python desired. You can check which is used withpip --version
. If you wantpip
to default to e.g. the latest Python, deleteC:\Python33\Scripts\pip.exe
and use the versioned executables (e.g.pip3.3
) for older versions. You may have to restart the command prompt/terminal for these changes to take effect. -
Now it should be possible to run
pip3.3 install [some package]
and install a package to Python 3.3.
Final Layout
After the steps above, the sample layout from the "Assumptions" section should now look like this:
C:\ Python32\ python32.exe Python33\ python33.exe Scripts\ pip3.3.exe Python34\ python.exe Scripts\ pip.exe pip3.4.exe
Notes
-
pip is also included by default in Python 2.7.9 and beyond in the Python2 series. ↩