【问题标题】:How can I install Basemap in Python 3 / Matplotlib 2 on Ubuntu 16.04?如何在 Ubuntu 16.04 上的 Python 3 / Matplotlib 2 中安装 Basemap?
【发布时间】:2018-03-15 14:17:02
【问题描述】:

我试过了

pip3 install basemap

Basemap 似乎不在 PyPI 上。

an old question,但没有答案。

我做了什么

  1. 我下载了底图 1.07 (source)
  2. 已安装 Matplotlib 2、numpy 1.11、PIL、python3-dev

我不确定在哪里/如何获得 GEOS (libgeos-dev?)。我想我遵循了 README 并没有显示任何错误,但是在尝试 this 的第一行时

$ python3
>>> from mpl_toolkits.basemap import Basemap

我明白了

ImportError: libgeos-3.3.3.so: cannot open shared object file: No such file or directory

在里面

$ locate libgeos-3.3.3.so
/home/math/Downloads/basemap-1.0.7/geos-3.3.3/src/.libs/libgeos-3.3.3.so
/usr/local/lib/libgeos-3.3.3.so

【问题讨论】:

标签: python-3.x matplotlib ubuntu-16.04 matplotlib-basemap


【解决方案1】:

在 Ubuntu 中,这对我有用:

$ sudo apt-get install libgeos-dev
$ pip install --user https://github.com/matplotlib/basemap/archive/master.zip

为了完整起见,如果您知道需要特定版本,可以将鼠标悬停在您需要的软件包/版本号 here 上找到下载链接。例如,如果我需要安装 v1.1.0,我可以使用上面的,将第二行替换为:

$ pip install --user https://github.com/matplotlib/basemap/archive/v1.1.0.zip

【讨论】:

  • 很好,它对我有用!请注意:如果您在虚拟环境中,--user 选项将不起作用
  • @kitsiosk 你在 python3 上安装了吗?
  • @Raj 是的,你遇到什么问题了吗?
  • 对我来说,最后一个命令在“底图的构建轮 (setup.py)”步骤中导致错误:src/_geoslib.c:4:10 抱怨 Python.h 不存在。在 Ubuntu 20.04 上使用 Python 3.6
  • sudo -H apt-get install python.3.6-dev -y 解决了这个问题
【解决方案2】:

试试这个:

sudo apt-get install libgeos-dev

sudo pip3 install -U git+https://github.com/matplotlib/basemap.git  # latest Version from Source

旧版本可能与 matplotlib 不兼容。

【讨论】:

  • 这个和上一个答案有什么区别?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-16
  • 1970-01-01
  • 2016-08-24
  • 2016-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多