[英]Installing Basemap with Python3.6 on Ubuntu 18.04
在过去的几个小时里,我一直在尝试启动并运行Basemap 。 按照本教程我运行:
venv
在 Pycharm 上的 venv 中conda install basemap
。 安装按计划进行,我在终端中收到一条消息,指出 basemap-1.2.0 已安装。 运行我的程序时:
Downloading and Extracting Packages
proj4-5.0.1 | 7.0 MB | ############################################################################################################################################################################################################################### | 100%
certifi-2018.10.15 | 139 KB | ############################################################################################################################################################################################################################### | 100%
libgcc-ng-8.2.0 | 7.6 MB | ############################################################################################################################################################################################################################### | 100%
libstdcxx-ng-8.2.0 | 2.9 MB | ############################################################################################################################################################################################################################### | 100%
pyshp-1.2.12 | 35 KB | ############################################################################################################################################################################################################################### | 100%
pyproj-1.9.5.1 | 64 KB | ############################################################################################################################################################################################################################### | 100%
openssl-1.0.2p | 3.5 MB | ############################################################################################################################################################################################################################### | 100%
conda-4.5.11 | 1.0 MB | ############################################################################################################################################################################################################################### | 100%
geos-3.6.2 | 1.6 MB | ############################################################################################################################################################################################################################### | 100%
basemap-1.2.0 | 15.2 MB | ############################################################################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Traceback (most recent call last):
File "/home/PycharmProjects/first_prog/venv/test.py", line 5, in <module>
from mpl_toolkits.basemap import Basemap
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'
我看到一些答案指出应该从源代码安装 Basemap 而不是使用 conda,所以我从源代码安装了 Basemap。
我首先安装了geos。 从 basemap-1.xx 目录切换到 geos 目录,设置 GEOS_DIR 环境变量。
basemap-1.x.x $ cd geos-3.3.3
basemap-1.x.x/geos-3.3.3 $ export GEOS_DIR=~/
basemap-1.x.x/geos-3.3.3 $ ./configure --prefix=$GEOS_DIR
basemap-1.x.x/geos-3.3.3 $ make <---- ERROR HERE
basemap-1.x.x/geos-3.3.3 $ make install
在运行make
命令时,我收到此错误:
Makefile:373: recipe for target 'IndexedPointInAreaLocator.lo' failed
make[4]: *** [IndexedPointInAreaLocator.lo] Error 1
make[4]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm/locate'
Makefile:392: recipe for target 'check-recursive' failed
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm/locate'
Makefile:444: recipe for target 'check-recursive' failed
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm'
Makefile:476: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src'
Makefile:368: recipe for target 'check-recursive' failed
make: *** [check-recursive] Error 1
有几种解决此错误的方法,但都没有奏效。 我尝试使用CheckInstall ,遵循此线程,尝试使用DNF ,遵循这些命令等等,但没有任何效果。
ImportError: Ubuntu 16.04.3 - 在 python 2.7.12 上安装底图模块是相关的,但错误仍然存在。
安装 Basemap与make
错误有关,但make: *** [all-recursive] Error 1
仍然存在。
我究竟做错了什么? 安装 Basemap 真的这么难吗? 我完全被困在这里,非常感谢任何帮助。
下面的方法应该有效。 您可以在此处下载存档。
pip install --upgrade --user matplotlib numpy pyproj pyshp OWSLib Pillow
sudo apt install libgeos-dev
pip install --user --upgrade basemap-1.2.0rel.tar.gz
我发现这个脚本对我有用。 它与其他答案略有不同,因为它下载并安装底图而无需单独下载。
pip install --upgrade --user matplotlib numpy pyproj pyshp OWSLib Pillow
sudo apt-get update
sudo apt install libgeos-dev
pip install --user https://github.com/matplotlib/basemap/archive/master.zip
我遇到了完全相同的问题:甚至是相同的错误。 似乎当我使用更高版本的 g++/gcc(~v7.4) 来编译旧版本的 geos(对我来说是~3.3.0)时,出现了这个问题。
然后我去https://trac.osgeo.org/geos/获取3.8.0版本的geos,仍然使用普通的gcc/g++,一切都很好。
希望这可以帮助您和其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.