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

Syntaxis error in widgets.py: #440

Open
juanbolso opened this issue Jul 30, 2023 · 2 comments
Open

Syntaxis error in widgets.py: #440

juanbolso opened this issue Jul 30, 2023 · 2 comments

Comments

@juanbolso
Copy link

juanbolso commented Jul 30, 2023

Hi,

I am having troubles trying to use the ipyvolume library.
I have installed it using conda and defining a conda environment.
At first I tried to use it in VSCode but some problem with the widgets prevented ipyvolume to show the 3d interactive plot properly.
Anyway, I went to the safer jupyter lab way ran in a browser (in this case Chrome Version 115.0.5790.110):

This is my jupyter version (and sub-versions):
IPython : 8.14.0
ipykernel : 5.5.5
ipywidgets : 8.0.7
jupyter_client : 8.3.0
jupyter_core : 5.3.1
jupyter_server : 2.7.0
jupyterlab : 4.0.3
nbclient : 0.8.0
nbconvert : 7.7.3
nbformat : 5.9.1
notebook : 7.0.0
qtconsole : not installed
traitlets : 5.9.0

And this is my python version (also installed in the conda environment I called jupyterEnv):
python 3.9.2

Conda version:
conda 23.7.2

Here is the error that jupyter lab gives when trying to import ipyvolume library:

Traceback (most recent call last):

File ~/Desktop/CondaEnv/miniconda3/envs/jupyterEnv/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3508 in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

Cell In[1], line 16
from ipyvolume import *

File ~/Desktop/CondaEnv/miniconda3/envs/jupyterEnv/lib/python3.9/site-packages/ipyvolume/init.py:8
from ipyvolume.widgets import * # noqa: F401, F403

File ~/Desktop/CondaEnv/miniconda3/envs/jupyterEnv/lib/python3.9/site-packages/ipyvolume/widgets.py:157
return pythreejs.ShaderMatshow_max = traitlets.CFloat(1).tag(sync=True)ew').tag(sync=True)
^
SyntaxError: invalid syntax

Finally, I want to say that some time ago I used this library also in Ubuntu, and it worked perfectly at that moment.
Something is off here :( In some of my attempts to fix this (trying in another environment to (un)-install other packages, use other pyhton version, etc) sometimes I got this error: AttributeError: module 'ipyvolume' has no attribute '_version'.

I would really appreciate any help with this issue!

Regards, Juan.

@juanbolso
Copy link
Author

Hi again,

I have installed all from scratch because I found that the widgets.py file I had in my pc was (for some strange reason) different from the widgets.py file in the master branch of the ipyvolume repo.

Now I have a different error which may be due to a circular import (according to the error message):

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb](https://file+.vscode-resource.vscode-cdn.net/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb) Cell 2 line 1
     [14](vscode-notebook-cell:/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb#W1sZmlsZQ%3D%3D?line=13) from IPython.display import display
     [15](vscode-notebook-cell:/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb#W1sZmlsZQ%3D%3D?line=14) from ipywidgets import VBox
---> [16](vscode-notebook-cell:/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb#W1sZmlsZQ%3D%3D?line=15) from ipyvolume import *
     [17](vscode-notebook-cell:/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb#W1sZmlsZQ%3D%3D?line=16) import ipyvolume as ipv # https://ipyvolume.readthedocs.io/en/latest/install.html
     [18](vscode-notebook-cell:/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/planetHsurface_withIntegration.ipynb#W1sZmlsZQ%3D%3D?line=17) from matplotlib import cm

File [~/Desktop/CondaEnv/miniconda3/envs/astroEnv/lib/python3.11/site-packages/ipyvolume/__init__.py:8](https://file+.vscode-resource.vscode-cdn.net/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/~/Desktop/CondaEnv/miniconda3/envs/astroEnv/lib/python3.11/site-packages/ipyvolume/__init__.py:8)
      6 from ipyvolume import datasets  # noqa: F401
      7 from ipyvolume import embed  # noqa: F401
----> 8 from ipyvolume.widgets import *  # noqa: F401, F403
      9 from ipyvolume.transferfunction import *  # noqa: F401, F403
     10 from ipyvolume.pylab import *  # noqa: F401, F403

File [~/Desktop/CondaEnv/miniconda3/envs/astroEnv/lib/python3.11/site-packages/ipyvolume/widgets.py:30](https://file+.vscode-resource.vscode-cdn.net/home/jpons/Desktop/CondaEnv/CODIGOS/Hamiltoniano/Hasigma_planetario/MODULAR/~/Desktop/CondaEnv/miniconda3/envs/astroEnv/lib/python3.11/site-packages/ipyvolume/widgets.py:30)
     22 from ipyvolume.traittypes import Image
     23 from ipyvolume.serialize import (
     24     array_cube_tile_serialization,
     25     array_serialization,
   (...)
     28     texture_serialization,
     29 )
---> 30 from ipyvolume.transferfunction import TransferFunction
...
     22 @widgets.register
     23 class TransferFunction(widgets.DOMWidget):
     24     _model_name = Unicode('TransferFunctionModel').tag(sync=True)

AttributeError: partially initialized module 'ipyvolume' has no attribute '_version' (most likely due to a circular import)

@juanbolso
Copy link
Author

Well, I don't know why but after re-installing everything and re-booting VSCode, it's working :D

Here is the plot I am generating:
image

However, I am having troubles to do almost anything with this interactive 3D plot. For example, I cannot change the resolution neither I can't save a capture of it because the following popup appears:

image

If I press OK then another message (from VSCode) appears:
image

and if I press cancel, then goes back to the 3D plot but without any intended changes having effect.

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

No branches or pull requests

1 participant