Monday, February 25, 2019

Fixing geopandas and osmnx problem: Could not find libspatialindex_c library file

For secondary problem trying to resolve (trying to find the library i got):
Traceback (most recent call last):
  File "", line 1, in
NameError: name 'find_library' is not defined

The solution is:

import ctypes
from ctypes.util import find_library
 
When you install environment and install geopandas, rtree and osmnx
 
pip install git+git://github.com/geopandas/geopandas.git
pip install rtree
pip install osmnx
 
No error, everythong aparently is ok, and you try to test

$python

>>> import rtree
Traceback (most recent call last):
 File "", line 1, in
 File "/var/www/sampleapp/crivist/myEnv/lib/python3.5/site-packages/rtree/__init__.py", line 1, in
   from .index import Rtree
 File "/var/www/sampleapp/crivist/myEnv/lib/python3.5/site-packages/rtree/index.py", line 5, in
   from . import core
 File "/var/www/sampleapp/crivist/myEnv/lib/python3.5/site-packages/rtree/core.py", line 125, in
   raise OSError("Could not find libspatialindex_c library file")
OSError: Could not find libspatialindex_c library file


You can solve using:
sudo apt install python3-rtree
But in some servers, you can't access to apt, then you decide do next commands:

$git clone https://github.com/libspatialindex/libspatialindex.git
$cd libspatialindex
$cmake --prefix=/usr .
$make
$sudo make install  #You cannot install on system


CMake Error at src/cmake_install.cmake:52 (file):
  file INSTALL cannot copy file
  "/home/fincahuanaco/Temp/libspatialindex/bin/libspatialindex.so.5.0.0" to
  "/usr/local/lib/libspatialindex.so.5.0.0".
Call Stack (most recent call first):
  cmake_install.cmake:42 (include)

But you compile, then you have the link to file, then set next variable

export SPATIALINDEX_C_LIBRARY=environmentpath/lib/libspatialindex_c.so


Enjoy
 


References:
[1] geopandas http://geopandas.org/install.html
[2] python environment https://docs.python-guide.org/dev/virtualenvs/
[3] python environment 2 https://docs.python.org/3/tutorial/venv.html

No comments:

Running apps

Runtastic (I uninstalled because force to update your device - Internet connection problems) Runkeeper  (Wrong GPS tracking) Strava   (Curr...