Ex46-pip uninstalling AttributeError

Shortly:
When I use “pip uninstall proto” to uninstall my module “proto”, an "AttributeError:‘EggMetadata’ object has no attribute ‘isdir’ "occurs.

Longly:
Just as the ex46 says, I create my own project named “prototype”, the directory tree is like below:

prototype/
    bin/
        hello.py
    docs/
    proto/
        __init__.py
        ex45a.py
        ex45b.py
    tests/
        __init__.py
        proto_test.py
    setup.py

Notes: The ex45a.py and ex45b.py are the games I wrote in ex45 and they work well. The hello.py is just a print function with shebang line.

And the config in setup.py is:

config = {
    'description': 'proto',
    'author': 'andrew',
    'url': 'URL to get it at.',
    'download_url': 'Where to download it.',
    'author_email': 'My email.',
    'version': '0.3',
    'install_requires': ['nose'],
    'packages': ['proto'],
    'scripts': ['bin/hello.py'],
    'name': 'proto'
}

The test result is good. Then I use “python setup.py install” command in terminal, the proto module gets installed successfully and it will show up in the “pip list” command output.
However when I use “pip uninstall proto”, an AttributeError occurs as below:
image
It seems that the EggMetadata didn’t involve the location information so the “isdir” attribute is null.
While I searched in the documents, I find that in pip documentation v22.0.4:

pip is able to uninstall most installed packages. Known exceptions are:
* Pure distutils packages installed with python setup.py install, which leave behind no metadata to determine what files were installed.

According to the distutils documents, my above “proto” module is exactly a pure distutils package, and I install it with “python setup.py install”, so I just can’t uninstall it with pip.
Here comes my question, how can you guys uninstall your module with pip since we do the similar things?
My environment:
Mac OS Montery v12.3.1; bashell; python3.7; distlib v0.3.4; pip v22.0.4; setuptools v60.10.0

1 Like

Problem solved.The culprit is the version of pip.
Pip v22.0.4 doesn’t support uninstalling a pure distutils package by “pip uninstall” command. However, when I changed the pip version to v9.0.1, no error occurs, my package “proto” get uninstalled successfully.
I hope it may help to anyone who gets stuck in the same trouble.

A free service run by Zed A. Shaw for learncodethehardway.org.