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

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

我正在尝试 pip install geopandas 作为全新安装,所以我想删除现有的软件包,例如 GDALfiona。我已经设法 pip uninstall fiona,但是当我尝试卸载或重新安装 GDAL 时,出现以下错误消息:

(base) C:\usr>pip install C:/usr/Anaconda3/Lib/site-packages/GDAL-3.4.1-cp38-cp38-win_amd64.whl
Processing c:\usr\anaconda3\lib\site-packages\gdal-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:\usr\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 405, in run
    installed = install_given_reqs(
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\req\__init__.py", line 68, in install_given_reqs
    uninstalled_pathset = requirement.uninstall(auto_confirm=True)
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\req\req_install.py", line 637, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\req\req_uninstall.py", line 554, in from_dist
    for script in dist.iterdir("scripts"):
  File "C:\usr\Anaconda3\lib\site-packages\pip\_internal\metadata\pkg_resources.py", line 156, in iterdir
    if not self._dist.isdir(name):
  File "C:\usr\Anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2816, in __getattr__
    return getattr(self._provider, attr)
AttributeError: 'PathMetadata' object has no attribute 'isdir'

有谁知道为什么GDAL无法卸载?

我在遇到同样的错误后才遇到这个问题。巧合的是我刚刚升级了 pip(我已经厌倦了黄色警告)。

我所拥有的只是降低我的点数

pip install pip==21.3.1 --user