From 706d1d9d244c7cf57d301d7d7b5d7b5188ec0870 Mon Sep 17 00:00:00 2001 From: samuel_chibe Date: Wed, 10 Jun 2026 08:04:17 +0100 Subject: [PATCH] Fix Open3D import crash when pybind stub directories exist (#7481) --- python/open3d/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/open3d/__init__.py b/python/open3d/__init__.py index 87608701d5c..676c9e91ac1 100644 --- a/python/open3d/__init__.py +++ b/python/open3d/__init__.py @@ -35,7 +35,11 @@ # Load CPU pybind dll gracefully without introducing new python variable. # Do this before loading the CUDA pybind dll to correctly resolve symbols try: # StopIteration if cpu version not available - CDLL(str(next((Path(__file__).parent / "cpu").glob("pybind*")))) + + CDLL(str(next( + p for p in (Path(__file__).parent / "cpu").glob("pybind*") + if p.is_file() + ))) except StopIteration: warnings.warn( "Open3D was built with CUDA support, but Open3D CPU Python " @@ -60,8 +64,10 @@ # Check CUDA availability without importing CUDA pybind symbols to # prevent "symbol already registered" errors if first import fails. - _pybind_cuda = CDLL( - str(next((Path(__file__).parent / "cuda").glob("pybind*")))) + _pybind_cuda = CDLL(str(next( + p for p in (Path(__file__).parent / "cuda").glob("pybind*") + if p.is_file() + ))) if _pybind_cuda.open3d_core_cuda_device_count() > 0: from open3d.cuda.pybind import ( core,