2

I checked the installed modules with help("modules")

I've tried uninstalling a module I did not want with pip uninstall somemodule, but I got this warning:

WARNING: Skipping somemodule as it is not installed.

In pip's documentation of pip uninstall it says in the description: Uninstall packages.

However in this answer it says that running pip uninstall somemodule will work.

Question:

  1. Can pip uninstall modules or only packages? I'm very confused.

  2. Will deleting the .py file in its directory, completely uninstall it, or is it a bad practice?

EDIT:

I have 2 versions of python installed. I ran all commands in python 3.9.1

py --version gives Python 3.9.1, and pip --version gives pip 21.0.1 from c:\...\python\python39\lib\site-packages\pip (python 3.9)

I've created a venv at some point. I deleted the folder shortly after creating the venv.

py -m pip uninstall somemodule also did not work

somemodule is the antigravity module that comes with python

Zero Pancakes
  • 276
  • 2
  • 12
  • you should use `pip uninstall` to remove modules as you previously did. Also, check in case you have multiple versions of python installed or maybe even a virtualenv as I think this may be the reason why the module is not uninstalled – tushortz Feb 15 '21 at 19:58
  • 1
    are you sure your python's environment running pip is the same as the environment where you ran help("modules") ? – Titouan Feb 15 '21 at 19:58
  • To elaborate on @Titouan answer, check that the interpreter in `pip --version` and `python --version` match. Given the transition from `python2` to `python3`, `python` may point to `python3` but `pip` usually points to `pip2` instead of `pip3` (or vice versa). – Jacob Faib Feb 15 '21 at 20:01
  • @ZeroPancakes First of all, `pip` installs or uninstalls distributions which happens to delete the associated packages and modules. What did you try to uninstall (i.e. what did you insert for `somemodule`)? Does `python -m pip uninstall ...` work? – a_guest Feb 15 '21 at 20:59
  • the problem may be someone's design decision, which allows you to install library `pillow` but import `PIL`. So when you try to uninstall `PIL` you will have to uninstall `pillow` otherwise pip will complain about missing module – JL0PD Feb 16 '21 at 02:14

1 Answers1

1

With pip you can install or uninstall distribution packages. These may contain any number of packages, modules or resource files. The antigravity module however is part of the standard library and hence cannot be removed by pip. If you really want to remove that module, you can identify its location in the following way and then remove it manually:

>>> import antigravity
>>> antigravity.__file__
'/path/to/lib/python3.9/antigravity.py'
$ rm lib/python3.9/antigravity.py

You can get a list of installed distributions via pip freeze and these are the ones you can remove as well. Note that sometimes the distribution name and the name of the top-level package that you import are not the same (e.g. you would do pip install scikit-learn and then import sklearn).

a_guest
  • 34,165
  • 12
  • 64
  • 118