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

Cannot import JVisualizer #659

Closed
djjacqmin opened this issue Nov 4, 2018 · 13 comments
Closed

Cannot import JVisualizer #659

djjacqmin opened this issue Nov 4, 2018 · 13 comments
Assignees
Labels

Comments

@djjacqmin
Copy link

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
@yxlao
Copy link
Collaborator

yxlao commented Nov 5, 2018

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

@djjacqmin
Copy link
Author

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

@syncle syncle added the question label Nov 6, 2018
@yxlao
Copy link
Collaborator

yxlao commented Nov 6, 2018

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?

@djjacqmin
Copy link
Author

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?

@yxlao
Copy link
Collaborator

yxlao commented Nov 7, 2018

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

@djjacqmin
Copy link
Author

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.

@TimZaman
Copy link

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

@griegler
Copy link
Contributor

@yxlao can you confirm

@pwais
Copy link

pwais commented Oct 1, 2020

+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

@edscher
Copy link

edscher commented Sep 27, 2022

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

For me this does not work. As reported in #5522

@firstmover
Copy link

not solving the problem for me

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

No branches or pull requests

10 participants