简体   繁体   中英

How to uninstall dependencies introduced by a Python package installed with Pip?

I tried to install PyLint. When installing I saw the following:

Collecting pylint
  Downloading pylint-1.6.5-py2.py3-none-any.whl (577kB)
    100% |████████████████████████████████| 583kB 655kB/s 
Collecting six (from pylint)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting isort>=4.2.5 (from pylint)
  Downloading isort-4.2.5-py2.py3-none-any.whl (40kB)
    100% |████████████████████████████████| 40kB 737kB/s 
Collecting mccabe (from pylint)
  Downloading mccabe-0.6.1-py2.py3-none-any.whl
Collecting configparser; python_version == "2.7" (from pylint)
  Downloading configparser-3.5.0.tar.gz
Collecting backports.functools-lru-cache; python_version == "2.7" (from pylint)
  Downloading backports.functools_lru_cache-1.3-py2.py3-none-any.whl
Collecting astroid<1.5.0,>=1.4.5 (from pylint)
  Downloading astroid-1.4.9-py2.py3-none-any.whl (213kB)
    100% |████████████████████████████████| 215kB 713kB/s 
Collecting lazy-object-proxy (from astroid<1.5.0,>=1.4.5->pylint)
  Downloading lazy-object-proxy-1.2.2.tar.gz
Collecting wrapt (from astroid<1.5.0,>=1.4.5->pylint)
  Downloading wrapt-1.10.8.tar.gz
Building wheels for collected packages: configparser, lazy-object-proxy, wrapt
  Running setup.py bdist_wheel for configparser ... done
  Stored in directory: /Users/dkanesha/Library/Caches/pip/wheels/1c/bd/b4/277af3f6c40645661b4cd1c21df26aca0f2e1e9714a1d4cda8
  Running setup.py bdist_wheel for lazy-object-proxy ... done
  Stored in directory: /Users/dkanesha/Library/Caches/pip/wheels/06/d4/af/71508d0c69292f8c369ba3ae83cd85fabcd6956fd5709633b4
  Running setup.py bdist_wheel for wrapt ... done
  Stored in directory: /Users/dkanesha/Library/Caches/pip/wheels/19/8a/01/20cf74c3f38d49ef8e9b9aa7ffd38cefff79bad9f6f2c651f0
Successfully built configparser lazy-object-proxy wrapt
Installing collected packages: six, isort, mccabe, configparser, backports.functools-lru-cache, lazy-object-proxy, wrapt, astroid, pylint
Successfully installed astroid-1.4.9 backports.functools-lru-cache-1.3 configparser-3.5.0 isort-4.2.5 lazy-object-proxy-1.2.2 mccabe-0.6.1 pylint-1.6.5 six-1.10.0 wrapt-1.10.8

Can I uninstall the packages mentioned here Installing collected packages: six, isort, mccabe, configparser, backports.functools-lru-cache, lazy-object-proxy, wrapt, astroid, pylint to restore to the previous state, or could the "Installing collected packages" refer to packages previously installed too?

pip will pretty explicitly tell you what exactly it does. If required packages are already installed, they won't be listed in the "successfully installed" list and it will say "requirement already satisfied" instead. If a dependency was upgraded during the installation, it will explicitly say that it found a previous version, that it uninstalled the previous version and that it installed a new version.

So, yes, in your case it does not look like it upgraded any old packages and purely installed new packages, so uninstalling all those should revert you to your previous state.

There are two useful packages to deal with it.

Use the package pip-autoremove to uninstall package and its dependencies. You can also use pipdeptree to display a tree relationship of all installed packages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM