13

I am using windows10 64 bits, my os.name is 'nt', I used pip to install but its complaining about the spatialindex_c.dll

 File "C:\Users\Bachir\AppData\Local\Temp\pip-build-td64lrth\rtree\rtree\core.py", line 101, in <module>
   raise OSError("could not find or load spatialindex_c.dll")
 OSError: could not find or load spatialindex_c.dll

I downloaded rtree-0.8.2 and then run python setup.py install and i have the same message

PS C:\Users\Bachir\documents\Python Scripts\Rtree-0.8.2> python setup.py install
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import rtree
File "C:\Users\Bachir\documents\Python Scripts\Rtree-0.8.2\rtree\__init__.py", line 1, in <module>
from .index import Rtree
File "C:\Users\Bachir\documents\Python Scripts\Rtree-0.8.2\rtree\index.py", line 6, in <module>
from . import core
File "C:\Users\Bachir\documents\Python Scripts\Rtree-0.8.2\rtree\core.py", line 101, in <module>
raise OSError("could not find or load spatialindex_c.dll")
OSError: could not find or load spatialindex_c.dll
PS C:\Users\Bachir\documents\Python Scripts\Rtree-0.8.2>  

I donwloaded the spatialindex dll files ' libspatialindex-1.8.1-win-msvc-2010-x64-x32.zip ' . this file contain both 32 and 64 bits , unzip and put in the installation folder, when installing using python setuo.py install it still complaining about the spatialindex dll file

14

Please, look at How can I install pyproj into arcpy?

1) the RTree module needs to be compiled with a version of libspatialindex installed in the system (your computer) and not simply adding spatialindex dll after
2) Windows has no compiler by default as in Linux or Mac OS X therefore you cannot install RTree with pip or setup.py install
3) in the Python Package Index page of RTree, bellow Download there is specified

Windows binaries http://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree

The files are Rtree-0.8.2-cp27-none-win32.whl and Rtree-0.8.2-cp27-none-win_amd64.whl

To install a whl file, download the file and

pip install Rtree-0.8.2-cp27-none-....whl (32 or 64)
3
  • Rtree-0.8.2-cp27-none-win32.whl is not supported on python34 platfom – bhalitim Feb 6 '16 at 16:58
  • Then you need to compile Rtree with a version of libspatialindex but I cannot help you because I do not use Windows – gene Feb 6 '16 at 18:13
  • Is it possible to include this downloaded wheel in your own package and to have pip install it from there? Right now I can't specify rtree as a dependency... – Robin De Schepper Jan 7 '20 at 14:21
3

I had the same problem and solved it by changing the core.py file in Rtree in

C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\rtree\core.py

and changed this line :

rt = _load_library('spatialindex_c.dll', ctypes.cdll.LoadLibrary)

by this :

rt = _load_library('spatialindex_c-64.dll', ctypes.cdll.LoadLibrary)
0

For users using Anaconda on Windows 64 bit machines:

Rtree plays an important role in Python GIS packages like geopandas, proj, pyproj etc.

I had same issue while importing geopandas in Jupyter notebook and I found out it was caused by RTree.

Now the solution to this particular problem:

OSError: could not find or load spatialindex_c-64.dll

Do these steps:

  1. Update python in your conda environment only using conda-forge channel like: conda install -c conda-forge python==3.7.10 . If you don't know what version of python to use just use what I used. You will see conda updates your python as cpython

  2. Now update rtree again using conda install rtree. Don't provide any channel here.

You're done here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.