python - 在 Ubuntu 18.04 上使用 Python3.6 安装底图
问题描述
在过去的几个小时里,我一直在尝试启动并运行Basemap 。按照本教程,我运行:
conda install basemap
在我venv
的 Pycharm 上。安装按计划进行,我在终端中收到一条消息,说明 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-get update
sudo apt install libgeos-dev
pip install --user https://github.com/matplotlib/basemap/archive/master.zip
推荐阅读
- jenkins - 获取 org.hidetake.groovy.ssh.session.BadExitStatusException:命令返回退出状态 1:在 Jenkins 管道执行中
- python - RadioButton tkinter:字符串索引必须是整数
- vstest - azure devops 发布管道中的 VSTest 任务问题
- rust - 由于权限提升,更改 PDA 拥有的令牌帐户权限失败
- spring - Spring Data JPA saveAll/Save 方法作为批量插入
- .htaccess - 如何将一些子域页面重定向到另一个页面 htaccess
- image - 如何在颤动中将图像大小压缩到 5MB
- javascript - 如何使用条件以角度为 mat-icon 应用颜色
- javascript - 挣扎使用带有状态的 react-redux 钩子
- reactjs - material ui popover 和 popper 之间的核心区别是什么?有什么不同的用例吗?