pip
uninstall package
Python
user install
package management

How to uninstall a package installed with pip install --user

Interview Questions practice on Codemia

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

Browse interview questions

Introduction

Packages installed with pip install --user are uninstalled with the normal pip uninstall command. The part that usually causes trouble is not the uninstall syntax but making sure you run pip through the same Python interpreter that owns the user-level package.

What --user Actually Changes

The --user flag tells pip to install into the user site-packages directory instead of the system-wide location. That is useful when:

  • you do not want administrator privileges,
  • you want to avoid changing the OS-managed interpreter,
  • you are not working inside a virtual environment.

Typical locations look like this:

  • Linux and macOS: ~/.local/lib/pythonX.Y/site-packages
  • Windows: %APPDATA%\Python\PythonXY\site-packages

The important point is that --user affects the install location, not the uninstall command. There is no separate pip uninstall --user mode you need to remember.

Use the Same Interpreter for Uninstall

The safest pattern is to invoke pip through Python itself:

bash
python -m pip uninstall requests

If you are using a specific version, be explicit:

bash
python3.11 -m pip uninstall requests

This matters because pip on your shell PATH might point to a different interpreter than python. When that happens, one command installs into the Python 3.11 user site and another command tries to uninstall from Python 3.10, which makes it look like the package is missing.

Verify Where the Package Lives

Before uninstalling, check that the package is really installed in the user site for the interpreter you plan to use.

bash
python -m pip show requests
python -m pip --version
python -m site --user-site

pip show prints the installation location, while site --user-site prints the user package directory for that interpreter. If those paths line up, you are targeting the right place.

You can also inspect the same information from Python code:

python
1import site
2import sys
3
4print(sys.executable)
5print(site.getusersitepackages())

That is especially handy in editors, notebooks, or background jobs where it is not obvious which interpreter is active.

What Happens in a Virtual Environment

Virtual environments change the answer completely. If a venv is active, python -m pip uninstall operates inside that environment, not in your user site-packages directory.

Example checks:

bash
python -c "import sys; print(sys.executable)"
python -m pip --version

If the executable path points into .venv, then uninstalling will affect the virtual environment only. That is often correct, but it surprises people who previously ran pip install --user outside the venv and later expected the same package to disappear from the global user site.

If your goal is to remove the user-level install, deactivate the virtual environment first or call the desired interpreter directly.

Confirm Removal and Handle Leftover Commands

After uninstalling, verify the result:

bash
python -m pip show requests

If pip show says the package is not found, the uninstall succeeded for that interpreter. If a command still appears to exist on the shell, one of three things is usually happening:

  • another Python installation still provides the same command,
  • the shell has cached the command path,
  • a leftover script remains in the user scripts directory.

On Unix-like systems, check where the command resolves:

bash
which black
python -m pip show black

On Windows, the equivalent command is:

powershell
Get-Command black
py -m pip show black

This tells you whether you are looking at the same installation source or a different one.

Multiple Python Versions Are the Real Source of Confusion

Most uninstall failures have nothing to do with --user itself. They come from having several interpreters on the same machine:

  • the system Python,
  • a Homebrew or package-manager Python,
  • 'pyenv,'
  • Conda,
  • one or more virtual environments.

In that setup, the correct rule is simple: uninstall with the interpreter that owns the package. Once you follow that rule, user-level installs behave predictably.

Common Pitfalls

  • Looking for a special --user uninstall flag even though standard pip uninstall is the right command.
  • Running pip uninstall from a different interpreter than the one that performed the install.
  • Forgetting that an active virtual environment changes which package set pip sees.
  • Assuming a leftover command means uninstall failed, when another Python installation still exposes it.
  • Using elevated commands such as sudo pip uninstall for packages that were installed only in the user site.

Summary

  • Packages installed with pip install --user are removed with the normal pip uninstall command.
  • Use python -m pip uninstall package_name so the correct interpreter performs the removal.
  • Verify the installation path with pip show and site --user-site when several Python environments exist.
  • Be careful with active virtual environments, because they redirect pip to a different site-packages location.
  • Most uninstall confusion comes from interpreter mismatch, not from the --user flag.

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.