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.
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:
If you are using a specific version, be explicit:
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.
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:
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:
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:
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:
On Windows, the equivalent command is:
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
--useruninstall flag even though standardpip uninstallis the right command. - Running
pip uninstallfrom a different interpreter than the one that performed the install. - Forgetting that an active virtual environment changes which package set
pipsees. - Assuming a leftover command means uninstall failed, when another Python installation still exposes it.
- Using elevated commands such as
sudo pip uninstallfor packages that were installed only in the user site.
Summary
- Packages installed with
pip install --userare removed with the normalpip uninstallcommand. - Use
python -m pip uninstall package_nameso the correct interpreter performs the removal. - Verify the installation path with
pip showandsite --user-sitewhen several Python environments exist. - Be careful with active virtual environments, because they redirect
pipto a different site-packages location. - Most uninstall confusion comes from interpreter mismatch, not from the
--userflag.
Related reading
- How to uninstall Python 2.7 on a Mac OS X 10.6.4?
- How to unnest explode a column in a pandas DataFrame, into multiple rows
- How to unpack pkl file
- How to unzip a folder in google colab?
- How to unzip a list of tuples into individual lists?
- How to update a plot in matplotlib
- How to update an existing Conda environment with a .yml file
- How to update metadata of an existing object in AWS S3 using python boto3?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.