Gettingerror: legacy-install-failure, while installing basemap

Gettingerror: legacy-install-failure, while installing basemap

我正在尝试使用 pip 安装 Basemap,但在某些时候出现错误:

note: This error originates from a subprocess, and is likely not a problem with pip.
      error: legacy-install-failure
      
      × Encountered error while trying to install package.
      ╰─> numpy
      
      note: This is an issue with the package mentioned above, not pip.
      hint: See above for output from the failure.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

我真的不知道该怎么办,也找不到遇到同样错误的人。我试过升级 pip 和 setuptools,但它们似乎没有帮助。我该怎么办?

P.S。在过去的 4 天里,我一直在尝试安装底图,但并不是很成功。如果你知道如何在 MacOS 上安装它,请联系我!谢谢!

对于Windows:

要安装 basemap,您需要从此路径下载 wheel 文件:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#basemap

对于 python 3.10 这将是文件:

basemap‑1.3.2‑cp310‑cp310‑win_amd64.whl

然后您必须转到保存上述 .whl 文件的文件夹,然后从那里 运行 此命令:

pip install basemap‑1.3.2‑cp310‑cp310‑win_amd64.whl


MacOS请参考:

https://github.com/matplotlib/basemap/releases:

确保你有:

brew install geos
brew install matplotlib
brew install numpy
brew install proj

export GEOS_DIR="/user/local/Cellar/geos/3.10.2/" 添加到您的 .bash 配置文件并通过以下方式重新加载:

source ~/.bash_profile

git clone --depth 1 https://github.com/matplotlib/basemap.git

然后在basemap/packages/basemap目录

pip3 install


对于 Google Colab:

!sudo apt-get install libgeos-3.6.2
!sudo apt-get install libgeos-dev
!pip install git+https://github.com/matplotlib/basemap#subdirectory=packages/basemap