Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No module named rtree" #941

Closed
Robert-Koenig-TUD opened this issue Aug 4, 2020 · 8 comments
Closed

"No module named rtree" #941

Robert-Koenig-TUD opened this issue Aug 4, 2020 · 8 comments

Comments

@Robert-Koenig-TUD
Copy link

Hello,
I want to check if a cube is inside (even partially) of a mesh.
Right now I try to use mesh.contains(points), but I get the Error message

in bounds_tree
import rtree
ModuleNotFoundError: No module named 'rtree'

I installed trimesh via pip install and its the newest version.

What can I do?

@mikedh
Copy link
Owner

mikedh commented Aug 4, 2020

Hey, looks like you're missing rtree. You can install via pip install rtree or pip install trimesh[easy] to get most of the soft runtime deps. pip install trimesh just installs the minimal requirements to import trimesh (i.e. numpy), to avoid a large mandatory dependency graph.

@warrenbocphet
Copy link

@mikedh not sure about other people here but I have never been able to install rtree through the official pip install, or through trimesh[easy]. It comes down to the fact that I'm missing some binaries that rtree depends on. I managed to resolve the issue by installing the unofficial wheel for rtree, which can be found here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree

@mikedh
Copy link
Owner

mikedh commented Aug 5, 2020

Yeah rtree really needs wheels built in CI. I took a stab at it here but didn't finish, if it ever makes it over the finish line I'll PR it back to them. If anyone wants to take up the wheel-mantle that would be great!

@Robert-Koenig-TUD
Copy link
Author

Hi, thank you for your answers. I tried to install rtree and trimesh[easy] but as @vitsensei already said there are some error messages and it didnt install.
I tried the wheel files but since I am quite new to programming I dont really know what to do with them.
I downloaded the latest files (both versions 32 and 64) and ran pip install "directory" and pip install wheel "directory" for both of the files, it didnt work.
The following error occures "'Directory to wheel file' is not a supported wheel on this platform.".

Any tips on how I am able to install rtree or use the mesh.contains function without rtree?

@warrenbocphet
Copy link

@RobertKoenig1337 I think you are very close Robert. You just need to download the correct wheel for your Python. What is the current version of your Python? If you like me and using 3.7, you should be downloading Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl (I'm using 64 bits machine).

@AymericFerreira
Copy link

AymericFerreira commented Aug 5, 2020

Hello,
I had some trouble to use rtree on a server (because of restriction on sudo and conda install). So here is my notes and it should work on all Linux computer.
Rtree need some environnemental variables to work so you need to set them, because Rtree use libspatialindex you need to have it :

curl -L http://download.osgeo.org/libspatialindex/spatialindex-src-1.8.5.tar.gz | tar xz
cd spatialindex-src-1.8.5
cmake -DCMAKE_INSTALL_PREFIX=path_to_spatialindex/spatialindex-src-1.8.5/ .
make && make install
export LD_LIBRARY_PATH=path_to_spatialindex/spatialindex-src-1.8.5/lib/
export SPATIALINDEX_C_LIBRARY=path_to_spatialindex/spatialindex-src-1.8.5/lib/libspatialindex_c.so

Then you should be able to do

pip install rtree
python
import rtree

@Robert-Koenig-TUD
Copy link
Author

@RobertKoenig1337 I think you are very close Robert. You just need to download the correct wheel for your Python. What is the current version of your Python? If you like me and using 3.7, you should be downloading Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl (I'm using 64 bits machine).

Thank you for your help. It worked with the right .whl file :D

@mshakerinava
Copy link

If you first install libspatialindex-dev, then rtree will install with no error.

sudo apt install libspatialindex-dev
pip install rtree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants