天天看點

GDAL、Geopandas、GeoJSON、Shapely、geopy、PyShp安裝

環境: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安裝

[[email protected] ~]# 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進行安裝:

[[email protected] ~]# /root/anaconda3/bin/pip install geojson
           

有的時候會報錯:

Traceback (most recent call last):
  File "/root/anaconda3/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main'
           

打開anaconda3下pip檔案

[[email protected] ~]# 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安裝成功:

[[email protected] ~]# 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