Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Cannot import JVisualizer

Open djjacqmin opened this issue 8 years ago • 14 comments

Describe the bug When I run the example code usage in the Jupyter Visualization section of the Open3D Documentation, I get the following error:

ImportError: cannot import name 'JVisualizer'

To Reproduce Steps to reproduce the behavior:

  1. Install open3d using conda in a dedicated environment
  2. Run the example code from the Jupyter Visualization section of the Open3D Documentation

Expected behavior Example usage produces expect result

Desktop (please complete the following information):

  • OS: macOS 10.13.6
  • Browser: Safari 12.0.1
  • Version: 0.4.0

djjacqmin avatar Nov 04 '18 16:11 djjacqmin

What python version is that? Could you please post the full terminal logs from installation to the import error?

yxlao avatar Nov 05 '18 02:11 yxlao

Python Version: Python 3.6.6 :: Anaconda custom (64-bit) Jupyter Version: 4.4.0

Here are the logs from running "conda install -n conda_open3d -c open3d-admin open3d -v" after uninstall:

dho-osx-sg8wn:~ jacqmin$ conda install -n conda_open3d -c open3d-admin open3d -v
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/jacqmin/anaconda3/envs/conda_open3d

  added / updated specs: 
    - open3d


The following NEW packages will be INSTALLED:

    open3d: 0.4.0.0-py36_0 open3d-admin

Proceed ([y]/n)? y

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... ===> LINKING PACKAGE: open3d-admin::open3d-0.4.0.0-py36_0 <===
  prefix=/Users/jacqmin/anaconda3/envs/conda_open3d
  source=/Users/jacqmin/anaconda3/pkgs/open3d-0.4.0.0-py36_0


done

Here's what I get when I run the example usage code in Jupyter.

`ImportError                               Traceback (most recent call last)
<ipython-input-1-3a21e503d668> in <module>
      1 import numpy as np
      2 import open3d as o3
----> 3 from open3d import JVisualizer
      4 
      5 pts_path = "examples/TestData/fragment.ply"

ImportError: cannot import name 'JVisualizer'`

djjacqmin avatar Nov 06 '18 15:11 djjacqmin

That's weird, i was able to get the jupyter working with py36, conda and Mac. Seems like you were able to import open3d but not the JVisulizer.

First, could you try if the following command work?

python -c "from open3d.j_visualizer import JVisualizer"

We can also locate the open3d package and check the init file

(open3d3-online) ➜  ~ python -c "import open3d as o3; print(o3)"
<module 'open3d.open3d' from '/Users/ylao/miniconda3/envs/open3d3-online/lib/python3.6/site-packages/open3d/open3d.cpython-36m-darwin.so'>

(open3d3-online) ➜  ~ cd /Users/ylao/miniconda3/envs/open3d3-online/lib/python3.6/site-packages/open3d/

(open3d3-online) ➜  ~/miniconda3/envs/open3d3-online/lib/python3.6/site-packages/open3d ls
__init__.py                  j_visualizer.py              static
__pycache__                  open3d.cpython-36m-darwin.so

(open3d3-online) ➜  ~/miniconda3/envs/open3d3-online/lib/python3.6/site-packages/open3d cat __init__.py

The init file shall look like this:

import importlib

globals().update(importlib.import_module('open3d.open3d').__dict__)

__version__ = '0.4.0.0'

if "ON" == "ON":
    from open3d.j_visualizer import *

    def _jupyter_nbextension_paths():
        return [{
            'section': 'notebook',
            'src': 'static',
            'dest': 'open3d',
            'require': 'open3d/extension'
        }]

Is that what you're getting?

yxlao avatar Nov 06 '18 18:11 yxlao

I'm seeing some differences between your output and mine. When I run python -c "from open3d.j_visualizer import JVisualizer", I get:

File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'open3d.j_visualizer'; 'open3d' is not a package

Here's what I get when I locate open3d:

(conda_open3d) dho-osx-sg8wn:site-packages jacqmin$ python -c "import open3d as o3; print(o3)"
<module 'open3d' from '/Users/jacqmin/.local/lib/python3.6/site-packages/open3d.cpython-36m-darwin.so'>
(conda_open3d) dho-osx-sg8wn:site-packages jacqmin$ cd /Users/jacqmin/.local//lib/python3.6//site-packages/
(conda_open3d) dho-osx-sg8wn:site-packages jacqmin$ ls
open3d.cpython-36m-darwin.so

Looks like I have the shared library but not the package files for some reason. Any thoughts?

djjacqmin avatar Nov 06 '18 20:11 djjacqmin

Looks like you're getting an incomplete package. Besides, this path doesn't look like a Conda path:

/Users/jacqmin/.local//lib/python3.6//site-packages/open3d.cpython-36m-darwin.so

While in your previous post the Conda path was in

/Users/jacqmin/anaconda3/envs/conda_open3d

I would suggest removing /Users/jacqmin/.local//lib/python3.6//site-packages/open3d.cpython-36m-darwin.so manually and create a new conda env and reinstall open3d. After installation, the following files should be present in the instllation path:

(open3d3-online) ➜  ~/miniconda3/envs/open3d3-online/lib/python3.6/site-packages/open3d ls
__init__.py                  j_visualizer.py              static
__pycache__                  open3d.cpython-36m-darwin.so

yxlao avatar Nov 07 '18 19:11 yxlao

Thanks @yxlao!

Problem solved. Turns out I had an earlier release that was installed with pip. Python, regardless of the environment, was using the pip-installed version rather than the version more recently installed with conda. Removing the problematic library manually and reinstalling open3d solved the problem.

djjacqmin avatar Nov 08 '18 21:11 djjacqmin

The tutorial just looks wrong at http://www.open3d.org/docs/release/tutorial/Basic/jupyter.html

Which states from open3d import JVisualizer while for me only this works: from open3d.j_visualizer import JVisualizer

TimZaman avatar Sep 22 '20 00:09 TimZaman

@yxlao can you confirm

griegler avatar Sep 22 '20 07:09 griegler

+1 I get a broken import as well (on HEAD). perhaps the tutorial is supposed to be updated to use https://github.com/intel-isl/Open3D/blob/664eff507e0f4d70f237d4a6531b1eff464948ad/examples/python/open3d_tutorial.py#L17 ?

that said, the tutorial itself ( http://www.open3d.org/docs/release/tutorial/Basic/jupyter.html ) might be outdated because I can run at least one of the tutorials in jupyter with "interactive" mode set to False

pwais avatar Oct 01 '20 09:10 pwais

https://github.com/isl-org/Open3D/blob/master/docs/jupyter/visualization/jupyter_visualization.ipynb

LifeBeyondExpectations avatar Sep 22 '22 22:09 LifeBeyondExpectations

https://github.com/isl-org/Open3D/blob/master/docs/jupyter/visualization/jupyter_visualization.ipynb

For me this does not work. As reported in https://github.com/isl-org/Open3D/issues/5522

edscher avatar Sep 27 '22 16:09 edscher

Same as @edscher https://github.com/isl-org/Open3D/blob/master/docs/jupyter/visualization/jupyter_visualization.ipynb not working as #5522

danielyan86129 avatar Jan 11 '23 23:01 danielyan86129

not solving the problem for me

firstmover avatar Jan 06 '24 22:01 firstmover

still unsolved

chansigit avatar Mar 26 '25 23:03 chansigit