环境:Centos7,包管理器conda,python3.6
(1)GDAL、GeoPandas、Shapely和PyShp安装
conda install gdal
conda install shapely
conda install -c conda-forge geopanda
conda install pyshp
(2)GeoJSON安装
[root@supervisor2 ~]# conda search geojson
Loading channels: done
PackagesNotFoundError: The following packages are not available from current channels:
- geojson
Current channels:
- https://repo.continuum.io/pkgs/main/linux-64
- https://repo.continuum.io/pkgs/main/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
在包管理conda下没有geojson库,这时候使用anaconda3自带的pip进行安装:
[root@supervisor2 ~]# /root/anaconda3/bin/pip install geojson
有的时候会报错:
Traceback (most recent call last):
File "/root/anaconda3/bin/pip", line 7, in
from pip import main
ImportError: cannot import name 'main'
打开anaconda3下pip文件
[root@supervisor2 ~]# vim /root/anaconda3/bin/pip
修改如下:
#!/root/anaconda3/bin/python
# -*- coding: utf-8 -*-
import re
import sys
#from pip import main
# 修改如下
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
再次运行pip安装命令:
/root/anaconda3/bin/pip install geojson
验证geojson安装成功:
[root@supervisor2 ~]# python
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import geojson
>>> exit()
(3)geopy安装
/root/anaconda3/bin/pip install geopy
备注:在windows下,包管理器是anaconda3,python版本是3.6
(1)下载geojson的whl文件
在https://www.lfd.uci.edu/~gohlke/pythonlibs/上下载geojson‑2.4.0‑py2.py3‑none‑any.whl包。
(2)使用anaconda3的pip进行安装
F:\Anaconda3\Scripts\pip install F:\geojson‑2.4.0‑py2.py3‑none‑any.whl