pip uninstall GDAL gives AttributeError: 'PathMetadata' object has no attribute 'isdir'

Question:

I’m trying to pip install geopandas as a fresh installation, so I want to remove existing packages like GDAL and fiona. I’ve already managed to pip uninstall fiona, but when I try to uninstall or reinstall GDAL it gives the following error message:

(base) C:usr>pip install C:/usr/Anaconda3/Lib/site-packages/GDAL-3.4.1-cp38-cp38-win_amd64.whl
Processing c:usranaconda3libsite-packagesgdal-3.4.1-cp38-cp38-win_amd64.whl
Installing collected packages: GDAL
  Attempting uninstall: GDAL
    Found existing installation: GDAL 3.0.2
ERROR: Exception:
Traceback (most recent call last):
  File "C:usrAnaconda3libsite-packagespip_internalclibase_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:usrAnaconda3libsite-packagespip_internalclireq_command.py", line 205, in wrapper
    return func(self, options, args)
  File "C:usrAnaconda3libsite-packagespip_internalcommandsinstall.py", line 405, in run
    installed = install_given_reqs(
  File "C:usrAnaconda3libsite-packagespip_internalreq__init__.py", line 68, in install_given_reqs
    uninstalled_pathset = requirement.uninstall(auto_confirm=True)
  File "C:usrAnaconda3libsite-packagespip_internalreqreq_install.py", line 637, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "C:usrAnaconda3libsite-packagespip_internalreqreq_uninstall.py", line 554, in from_dist
    for script in dist.iterdir("scripts"):
  File "C:usrAnaconda3libsite-packagespip_internalmetadatapkg_resources.py", line 156, in iterdir
    if not self._dist.isdir(name):
  File "C:usrAnaconda3libsite-packagespip_vendorpkg_resources__init__.py", line 2816, in __getattr__
    return getattr(self._provider, attr)
AttributeError: 'PathMetadata' object has no attribute 'isdir'

Does anyone know why GDAL cannot be uninstalled?

Asked By: lizard

||

Answers:

I just came across this question after getting the same error. Coincidentally I had just upgraded pip (I was getting tired of the yellow warnings).

All I had was to down grade my pip

pip install pip==21.3.1 --user
Answered By: deprekate

I was seeing the same AttributeError as you when trying to install google-cloud-firestore. My solution was to upgrade my version of pip. In my case, I upgraded to pip from 22.0.2 to 22.3.1

pip install --upgrade pip
Answered By: Ian Marcinkowski
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.