kylemart
kylemart

Reputation: 1276

`pip3 list` showing uninstalled package

Last week I installed awscli with pip3, and today I decided to uninstall it. The uninstall was successful, but pip3 list gives me the following output:

~
❯ pip3 list
Package           Version
----------------- ----------
-                 scli
-wscli            1.16.137
astroid           2.0.4
botocore          1.12.127
certifi           2018.10.15
colorama          0.3.9
docutils          0.14
isort             4.3.4
jmespath          0.9.4
lazy-object-proxy 1.3.1
mccabe            0.6.1
pip               19.0.3
pyasn1            0.4.5
pylint            2.1.1
python-dateutil   2.8.0
PyYAML            3.13
rsa               3.4.2
s3transfer        0.2.0
setuptools        40.8.0
six               1.11.0
urllib3           1.24.1
virtualenv        16.1.0
virtualenv-clone  0.4.0
wheel             0.33.1
wrapt             1.10.11

The top two entries appear to be related to awscli. Even the version number (1.16.137) is the same as awscli's. Anyone know how to resolve this issue?

EDIT:

Found this:

/usr/local/lib/python3.7/site-packages
❯ ls
__pycache__                       mccabe-0.6.1.dist-info            virtualenv.py
astroid                           mccabe.py                         virtualenv_clone-0.4.0.dist-info
astroid-2.0.4.dist-info           pip                               virtualenv_support
botocore                          pip-19.0.3-py3.7.egg-info         wheel
botocore-1.12.130.dist-info       pkg_resources                     wheel-0.32.2-py3.7.egg-info
certifi                           pylint                            wheel-0.33.0-py3.7.egg-info
certifi-2018.10.15.dist-info      pylint-2.1.1.dist-info            wheel-0.33.1-py3.7.egg-info
clonevirtualenv.py                setuptools                        wrapt
easy_install.py                   setuptools-40.8.0-py3.7.egg-info  wrapt-1.10.11.dist-info
isort                             sitecustomize.py                  ~-scli-1.16.137.dist-info
isort-4.3.4.dist-info             six-1.11.0.dist-info              ~wscli-1.16.137.dist-info
lazy_object_proxy                 six.py
lazy_object_proxy-1.3.1.dist-info virtualenv-16.1.0.dist-info

Safe to delete the two offending directories?

Upvotes: 1

Views: 1572

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123400

pip list takes this information from .dist-info entries in your path. You appear to have some extra names there, given your listing. Note the two entries at the end:

~-scli-1.16.137.dist-info
~wscli-1.16.137.dist-info

Simply delete these two directory entries.

Note that awscli did not create these directories, especially because pip would have used the universal wheel file to install awscli, so no setup script needed to be run when it was installed. They remind me of the Windows hidden lock files (which start with ~$), so perhaps they were created when you used another tool I'm not familiar with that may have accidentally left these lying around.

It doesn't really matter if those .dist-info entries are directories, symlinks, or files, all that pip list does is take all names that end in .dist-info then splits out version and name at the first -. You can create any phantom entry just by creating empty files:

$ mkdir demo && cd demo && virtualenv-3.8 .
# ....
$ bin/pip list  # new, empty virtualenv
Package    Version
---------- -------
pip        19.0.3
setuptools 41.0.0
wheel      0.33.1
$ touch lib/python3.8/site-packages/foobar-version.dist-info
$ bin/pip list  # surprise package listed
Package    Version
---------- -------
foobar     version
pip        19.0.3
setuptools 41.0.0
wheel      0.33.1

Upvotes: 4

Related Questions