Open3d: Cannot import JVisualizer

Created on 4 Nov 2018  Â·  9Comments  Â·  Source: intel-isl/Open3D

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
question

Most helpful comment

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

All 9 comments

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

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'`

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?

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?

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

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.

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

@yxlao can you confirm

+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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edxsx picture edxsx  Â·  3Comments

mike239x picture mike239x  Â·  3Comments

samarth-robo picture samarth-robo  Â·  3Comments

HaiyongJiang picture HaiyongJiang  Â·  3Comments

prerakmody picture prerakmody  Â·  3Comments