3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

(追記あり)「OSError: Could not find libspatialindex_c library file」発生時の対処法(MacOS環境)

Last updated at Posted at 2018-09-18

発生した問題について

実行環境

名前 環境
OS mac OS 10.13.6
プログラム言語 Python 3.5.2

発生した問題の概要

GISを使わずにPythonのみで地理空間データを可視化するために【脱GIS】Pythonとかで地理空間情報、位置情報を扱うための情報まとめ【随時更新】
より以下のようなソースコードを作成しました.

main.py
import osmnx as ox
import matplotlib.pyplot as plt
shinjuku = ox.gdf_from_place('Shinjuku')
shinjuku.plot()
plt.show()

これを実行させたところ次のようなエラーが発生しました.

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import osmnx as ox
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/osmnx/__init__.py", line 9, in <module>
    from .buildings import *
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/osmnx/buildings.py", line 9, in <module>
    import geopandas as gpd
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas.geoseries import GeoSeries
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/geopandas/geoseries.py", line 12, in <module>
    from geopandas.base import GeoPandasBase, _series_unary_op, _CoordinateIndexer
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/geopandas/base.py", line 14, in <module>
    from rtree.core import RTreeError
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/rtree/__init__.py", line 1, in <module>
    from .index import Rtree
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/rtree/index.py", line 5, in <module>
    from . import core
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/rtree/core.py", line 125, in <module>
    raise OSError("Could not find libspatialindex_c library file")
OSError: Could not find libspatialindex_c library file

問題の解決

解決方法

homebrewにてbrew install spatialindexを叩きインストールすることで解決しました.

「 spatialindex」ってなんぞや

こちらを和訳してもよく理解できなかったです・・・・どのようなものか理解したら追記しようと思います.

追記(2018/09/19)

MacOS環境では上記ソースコードの最後にplt.show()をつけないと地図が表示されませんでした.

correct_main.py
import osmnx as ox
import matplotlib.pyplot as plt
shinjuku = ox.gdf_from_place('Shinjuku')
shinjuku.plot()
plt.show()#追加箇所
3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?