1

在 Mac (Mojave 10.14.6) 上尝试将 SkewT 导入我的 python3 代码时:

从metpy.plots导入SkewT

我得到错误:

ModuleNotFoundError:没有名为“cartopy”的模块

pip3 install cartopy 给出输出

Collecting cartopy
  Downloading https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz (8.9MB)
     |████████████████████████████████| 8.9MB 616kB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Complete output from command /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpj50b1vfe:
  ERROR: setup.py:171: UserWarning: Unable to determine GEOS version. Ensure you have 3.3.3 or later installed, or installation may fail.
    '.'.join(str(v) for v in GEOS_MIN_VERSION), ))
  Proj 4.9.0 must be installed.
  ----------------------------------------
ERROR: Command "/usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpj50b1vfe" failed with error code 1 in /private/tmp/pip-install-b5cu8485/cartopy

首先,我尝试安装 Proj 和 geos,但 pip3 只列出了 proj 的 0.1.0 版本和 geos 的 0.2.2 版本。在我深入这个兔子洞之前,我想我会看看是否有其他人遇到过这个问题。谢谢!

4

3 回答 3

0

你用康达吗?解决此问题的最简单方法是通过 conda 安装 CartoPy(或 MetPy),以便同时下载所有正确的依赖项:conda install -c conda-forge cartopyconda install -c conda-forge metpy. Pip 并没有将它们全部放在一起,因此导致了这个问题的出现。

于 2019-09-12T18:47:24.237 回答
0

所以看起来 MetPy 0.10 意外地对 CartoPy 产生了硬依赖,而我们并没有真正计划过。您可以在此处跟踪我们的解决方案。

不幸的是,CartoPy 依赖于许多不可 pip 安装的编译库。最好的办法是查看CartoPy 的安装说明。如果您使用的是 Anaconda 或 Canopy,这些发行版会提供预构建的 CartoPy 包。

解决此问题的一种方法是安装 MetPy 0.9:

pip install metpy==0.9
于 2019-09-13T17:09:17.347 回答
0

谢谢。没有 conda,我也能够完成这个(更痛苦的)安装:

    - brew install geos
    - brew install proj
    - pip3 install cython
    - pip3 install git+https://github.com/SciTools/cartopy.git@master 
(see http://louistiao.me/posts/installing-cartopy-on-mac-osx-1011/)
于 2019-09-12T23:34:27.353 回答