原文地址:https://blog.csdn.net/qq_37598092/article/details/123652853
使用pip安裝Cartopy庫時,出現報錯:
1 Getting requirements to build wheel did not run successfully. 2 Getting requirements to build wheel did not run successfully. 3 │ exit code: 1 4 ╰─> [3 lines of output] 5 setup.py:117: UserWarning: Unable to determine GEOS version. Ensure you have 3.7.2 or later installed, or installation may fail. 6 warnings.warn( 7 Proj 8.0.0 must be installed.
輸入:
1 pip install Cartopy
報錯:
1 D:\app\python\python310\Scripts>pip install Cartopy 2 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 3 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 4 Collecting Cartopy 5 Using cached Cartopy-0.20.2.tar.gz (10.8 MB) 6 Installing build dependencies ... done 7 Getting requirements to build wheel ... error 8 error: subprocess-exited-with-error 9 10 × Getting requirements to build wheel did not run successfully. 11 │ exit code: 1 12 ╰─> [3 lines of output] 13 setup.py:117: UserWarning: Unable to determine GEOS version. Ensure you have 3.7.2 or later installed, or installation may fail. 14 warnings.warn( 15 Proj 8.0.0 must be installed. 16 [end of output] 17 18 note: This error originates from a subprocess, and is likely not a problem with pip. 19 error: subprocess-exited-with-error 20 21 × Getting requirements to build wheel did not run successfully. 22 │ exit code: 1 23 ╰─> See above for output. 24 25 note: This error originates from a subprocess, and is likely not a problem with pip. 26 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 27 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages)
於是,嘗試在https://www.lfd.uci.edu/~gohlke/pythonlibs/#numba下載並安裝whl文件:
輸入:
1 pip install Cartopy-0.20.2-pp38-pypy38_pp73-win_amd64.whl
出現成功安裝提示:
1 D:\app\python\python310\Scripts>pip install Cartopy-0.20.2-cp310-cp310-win_amd64.whl 2 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 3 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 4 Processing d:\app\python\python310\scripts\cartopy-0.20.2-cp310-cp310-win_amd64.whl 5 Collecting shapely>=1.6.4 6 Downloading Shapely-1.8.1.post1-cp310-cp310-win_amd64.whl (1.3 MB) 7 ---------------------------------------- 1.3/1.3 MB 2.2 MB/s eta 0:00:00 8 Requirement already satisfied: pyshp>=2.1 in d:\app\python\python310\lib\site-packages (from Cartopy==0.20.2) (2.2.0) 9 Requirement already satisfied: numpy>=1.18 in d:\app\python\python310\lib\site-packages (from Cartopy==0.20.2) (1.22.0) 10 Requirement already satisfied: matplotlib>=3.1 in d:\app\python\python310\lib\site-packages (from Cartopy==0.20.2) (3.5.1) 11 Requirement already satisfied: pyproj>=3.0.0 in d:\app\python\python310\lib\site-packages (from Cartopy==0.20.2) (3.3.0) 12 Requirement already satisfied: kiwisolver>=1.0.1 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (1.3.2) 13 Requirement already satisfied: cycler>=0.10 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (0.11.0) 14 Requirement already satisfied: packaging>=20.0 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (21.3) 15 Requirement already satisfied: pillow>=6.2.0 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (9.0.0) 16 Requirement already satisfied: python-dateutil>=2.7 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (2.8.2) 17 Requirement already satisfied: fonttools>=4.22.0 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (4.28.5) 18 Requirement already satisfied: pyparsing>=2.2.1 in d:\app\python\python310\lib\site-packages (from matplotlib>=3.1->Cartopy==0.20.2) (3.0.6) 19 Requirement already satisfied: certifi in d:\app\python\python310\lib\site-packages (from pyproj>=3.0.0->Cartopy==0.20.2) (2021.10.8) 20 Requirement already satisfied: six>=1.5 in d:\app\python\python310\lib\site-packages (from python-dateutil>=2.7->matplotlib>=3.1->Cartopy==0.20.2) (1.16.0) 21 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 22 Installing collected packages: shapely, Cartopy 23 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 24 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 25 Successfully installed Cartopy-0.20.2 shapely-1.8.1.post1 26 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages) 27 WARNING: Ignoring invalid distribution -ip (d:\app\python\python310\lib\site-packages)
但是,在pycharm中導入cartopy模塊時,出錯:
1 ImportError: DLL load failed: 找不到指定的模塊。
網上查找資料后,原因應該是cartopy模塊的依賴庫版本不對。
解決方案
cartopy包的依賴庫有:pyproj,Pillow,pyshp,Shapely
需要將這幾個庫卸載后,使用whl重新安裝。
1、卸載原有依賴庫
1 pip uninstall Pillow 2 pip uninstall pyshp 3 pip uninstall Shapely 4 pip uninstall pyproj
2、在https://www.lfd.uci.edu/~gohlke/pythonlibs/#numba中查找並下載這幾個庫和你電腦的對應版本
此處下載的是:
- Pillow-9.0.1-cp310-cp310-win_amd64.whl
- pyproj-3.3.0-cp310-cp310-win_amd64.whl
- pyshp-2.2.0-py3-none-any.whl
- Shapely-1.8.1.post1-cp310-cp310-win_amd64.whl
3、安裝庫
1 pip install --user Shapely-1.8.1.post1-cp310-cp310-win_amd64.whl 2 3 pip install --user pyproj-3.3.0-cp310-cp310-win_amd64.whl 4 5 pip install --user pyshp-2.2.0-py3-none-any.whl 6 7 pip install --user Pillow-9.0.1-cp310-cp310-win_amd64.whl
安裝完成后,在pycharm中導入cartopy模塊時不再報錯,成功。
問題解決。
————————————————
版權聲明:本文為CSDN博主「LorettaWang」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_37598092/article/details/123652853