如何修复 Cartopy pip install error 'Proj 4.9.0 must be installed.'

问题:

尝试使用例如 pip install -U cartopy 安装 cartopy 时,你看到此错误消息:

cartopy_proj_error.txt
Collecting cartopy
  Downloading Cartopy-0.19.0.post1.tar.gz (12.1 MB)
     |████████████████████████████████| 12.1 MB 13.2 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmp2q7tvpo8 get_requires_for_build_wheel /tmp/tmpfwd5htse
       cwd: /tmp/pip-install-dg2i313t/cartopy
  Complete output (1 lines):
  Proj 4.9.0 must be installed.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /tmp/tmp2q7tvpo8 get_requires_for_build_wheel /tmp/tmpfwd5htse Check the logs for full command output.

解决方案

使用例如以下命令安装 proj

install_proj.sh
sudo apt -y install libproj-dev

然后使用例如以下命令再次安装 cartopy

install_cartopy.sh
pip install -U cartopy

Check out similar posts by category: Cartopy, Geoinformatics, Python