Pip is an extremely useful tool for python programmers. While installing a module is frequent operation uninstalling is rarely used. Which make it unknown for many people. If you use virtual environment then it's even more complicated. In this article it's shown how to uninstall modules installed by pip install in virtual environment. The article is tested with python 2.7, 3.6 and 3.7.

Video tutorial: Python uninstall a module installed with pip install and virtual environment

Let say that you have installed a module/package wand by:

pip install wand

and now you want to uninstall it. This can be done simply by:

pip uninstall wand

I want to make several notes about installing and uninstalling in virtual environment by pip. Test environment is Linux Mint 19, python 3.6 and pip 9.0.1, virtual env is located:

/home/user/environments/venv36/
  • pip install package installs to:

    • /home/user/environments/venv36/lib/python3.6/site-packages

and uninstalling it does work using pip uninstall somepackage. So final folder for the module wand would be:

/home/user/environments/venv36/lib/python3.6/site-packages/wand
  • This is true only if you install it in virtual environment. Otherwise the packages goes into:

    • /home/user/.local/lib/python3.6/site-packages
    • /home/user/.local/lib/python3.7/site-packages
  • In order to use pip of a virtual environment you need to activate/use it:

    • activate pip by: source ./bin/activate and then install the package
    • enter the full pip path: /home/user/environments/venv36/bin/pip install wand(especially on windows because of the lack of good terminal and history of executed commands)
    • Use PyCharm terminal - where the virtual environment is activated for you (on windows the terminal may not work)
  • use pip -V to see the pip and python version

  • use pip freeze in order to see installed modules

  • this command:

pip uninstall somepackage

remove the content of:

/home/user/environments/venv36/lib/python3.6/site-packages/wand
  • pip install module run on virtual environment install the module only on this environment and not globally

  • using --user like:

pip install --user wand

By default pip installs Python modules to a system folder like:

/usr/local/lib/python3.6

Which will require root privileges while adding --user change pip to install packages in your home directory instead.

Useful pip commands for beginners:

# install module virtual environment
cd ./my/env
source ./bin/activate
pip install wand

# install module system
pip install wand

# install module
pip install --user wand

# uninstall module
pip uninstall wand

# check modules
pip freeze

# check pip version
pip -V