Python 3.7
pip installation
Ubuntu 18.04
Python package management
Linux tutorial

How can I Install pip for python 3.7 on Ubuntu 18?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On Ubuntu 18.04, python3-pip installs pip for the system's default Python 3, which is usually Python 3.6, not Python 3.7. If you specifically need pip tied to python3.7, the safest approach is to make sure Python 3.7 and its support packages are present, then bootstrap pip for that interpreter directly.

Confirm Python 3.7 Exists First

Start by checking whether python3.7 is already installed:

bash
python3.7 --version

If that command fails, install Python 3.7 first. On Ubuntu 18.04, many developers used the deadsnakes repository for newer Python builds:

bash
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7 python3.7-venv python3.7-distutils

The distutils package matters because older pip bootstrap methods often depend on it, and venv is useful if you want isolated environments afterward.

Install pip for Python 3.7

Once python3.7 is available, download the pip bootstrap script for Python 3.7 and run it with that interpreter:

bash
curl -sS https://bootstrap.pypa.io/pip/3.7/get-pip.py -o get-pip.py
python3.7 get-pip.py

If your environment requires elevated privileges for system-wide installation, use:

bash
sudo python3.7 get-pip.py

After installation, verify that the pip you are invoking belongs to Python 3.7:

bash
python3.7 -m pip --version

Using python3.7 -m pip is the most reliable habit because it guarantees you are talking to the correct interpreter.

Install Packages the Right Way

Once pip is installed, prefer this style:

bash
python3.7 -m pip install requests

That is better than relying on a bare pip or pip3 command, because those names may point to a different Python installation on the same machine.

You can also upgrade pip itself this way:

bash
python3.7 -m pip install --upgrade pip

And inspect installed packages:

bash
python3.7 -m pip list

Consider Using a Virtual Environment

If the goal is project work rather than system administration, create a virtual environment with Python 3.7 and install packages there:

bash
python3.7 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip

This avoids mixing project dependencies into the global interpreter and makes the setup easier to reproduce.

Inside the virtual environment, python and pip point at the environment automatically, which reduces version confusion.

Troubleshooting Common Problems

If python3.7 -m pip still fails after bootstrapping, check that the installation path is on your environment or keep using the explicit interpreter form. The explicit form is usually enough and does not require shell alias changes.

If curl is unavailable, you can fetch the bootstrap script with wget instead:

bash
wget https://bootstrap.pypa.io/pip/3.7/get-pip.py
python3.7 get-pip.py

If SSL or certificate errors appear during package installation, first upgrade pip and make sure system certificates are current. Those failures are usually network or trust-store problems, not Python 3.7 problems specifically.

Common Pitfalls

The biggest mistake is installing python3-pip and assuming it automatically attaches to Python 3.7. On Ubuntu 18.04, that package typically follows the default Python 3 interpreter.

Another common issue is using plain pip3 after installing multiple Python versions. The command may work, but it may install into the wrong site-packages directory.

It is also easy to forget python3.7-distutils or python3.7-venv, which can make bootstrapping or environment setup more frustrating than it needs to be.

Summary

  • Check python3.7 --version first so you know the interpreter exists.
  • Install python3.7, python3.7-venv, and python3.7-distutils if needed.
  • Bootstrap pip with python3.7 get-pip.py.
  • Prefer python3.7 -m pip ... over bare pip commands.
  • Use a virtual environment when the packages are for a project rather than the whole machine.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.