isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.36k stars 2.29k forks source link

At import: ModuleNotFoundError: No module named 'open3d.cpu.pybind' #4917

Open leope892 opened 2 years ago

leope892 commented 2 years ago

Checklist

Describe the issue

Hello! I'm using Ubuntu 20.04.4 and am having issues with importing Open3D in Python. I have installed the library with pip (version 22.0.4) and am using Python version 3.10.0. At the "import open3d" line in Python I get an immediate module error. I have also tried to build the library from source as per the doc instructions, but then also similarly get an error that seems to involve "pybind" at the step where the Open3D Python library is installed (executing "make python-package" from ./Open3D/build), although I'm not sure how to interpret the error message.

Steps to reproduce the bug

Steps to reproduce the bug:
In Ubuntu 20.04.4 install the Open3D Python library with "pip install open3d" (pip version 22.0.4). Then with the line "import open3d" in a Python compiler (Python version 3.10.0), execute the code.

Error message

Importing in Python compiler:

ModuleNotFoundError Traceback (most recent call last) /tmp/ipykernel_913513/1479048614.py in 11 import laspy as lp 12 import os ---> 13 import open3d as o3d

~/.local/lib/python3.9/site-packages/open3d/init.py in 88 89 if __DEVICE_API__ == 'cpu': ---> 90 from open3d.cpu.pybind import (camera, data, geometry, io, pipelines, 91 utility, t) 92 from open3d.cpu import pybind

ModuleNotFoundError: No module named 'open3d.cpu.pybind'

Building from source:

make python-package Error removing directory "/home/ubuntu/lidar/Open3D/build/bin/resources/html". make[3]: [cpp/open3d/visualization/webrtc_server/CMakeFiles/copy_html_dir.dir/build.make:70: cpp/open3d/visualization/webrtc_server/CMakeFiles/copy_html_dir] Error 1 make[2]: [CMakeFiles/Makefile2:3173: cpp/open3d/visualization/webrtc_server/CMakeFiles/copy_html_dir.dir/all] Error 2 make[1]: [CMakeFiles/Makefile2:3678: cpp/pybind/CMakeFiles/python-package.dir/rule] Error 2 make: [Makefile:1112: python-package] Error 2

Expected behavior

For "import open3d" to not cause a module error.

Open3D, Python and System information

- Operating system: Ubuntu 20.04.4
- Python version: Python 3.10.0
- Open3D version: cannot `print(open3d.__version__)`
- System architecture: x86_64
- Is this a remote workstation?: yes
- How did you install Open3D?: pip
- Compiler version (if built from source): gcc 9.4.0

Additional information

No response

yuecideng commented 2 years ago

It seems that python3.10 is not supported currently by Open3D. reference Maybe you can try python3.8 or python3.9?

leope892 commented 2 years ago

I get the same error when trying Python3.9 and Python3.8.

I've never tried to have multiple Python versions before so I might have done something less than ideal, but I created a virtual environment ("python3 -m venv py3.9_env" then "source py.39_env/bin/activate" to activate the environment) and I downloaded pyenv to be able to switch to version 3.9 ("pyenv install 3.9.0" then "pyenv global 3.9.0" to activate the version). (I did the same process all over again when trying out Python3.8.)

After this procedure and then using "pip install open3d", I still get the same import error when running the code. (I made sure that sys.path only contained the path where the relevant open3d package lied so that it didn't mix up versions.)

Any ideas?

sungminlee114 commented 2 years ago

Same problem for me.

Based on http://www.open3d.org/docs/latest/compilation.html, after cmake,

  1. sudo make install-pip-package
  2. sudo make pip-package

both results in

[100%] Built target python-package
Warning: cannot import "wheel" package to build platform-specific wheel
Install the "wheel" package to fix this warning
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'
make[3]: *** [cpp/pybind/CMakeFiles/pip-package.dir/build.make:70: cpp/pybind/CMakeFiles/pip-package] Error 1
make[2]: *** [CMakeFiles/Makefile2:3330: cpp/pybind/CMakeFiles/pip-package.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:3363: cpp/pybind/CMakeFiles/install-pip-package.dir/rule] Error 2
make: *** [Makefile:1047: install-pip-package] Error 2
  1. make python-package : I get a permission error.
  2. sudo make python-package : It success building, but I have to manually mv (build)/lib/python_package/open3d MY_PYTHON_PACKAGE_PATH/open3d, and gets No module named 'open3d.cpu.pybind'

My environment is

sungminlee114 commented 2 years ago

I've managed to solve it myself. The problem was multiple versions of python.

I had python versions 3.7 and 3.8 undivided by any venvs. I wanted to install open3d on 3.8, but find_package(Python3 3.6 COMPONENTS Interpreter Development) in CMakeLists.txt keeps finding the old(3.7) python package. So the installation was going under python 3.7.

After spotting the problem, I tried to solve the issue by passing some cmake arguments: Python_EXECUTABLE, Python_INCLUDE_DIR, and Python_FIND_STRATEGY=VERSION, but it didn't work.

So I just had to install the python version 3.7 and it all went fine.

I hope this helps @leope892 and others.