d3blocks / d3blocks

The Python library to create stand-alone and interactive d3 charts.
GNU General Public License v3.0
566 stars 52 forks source link

error to import d3blocks in jupyter notebook #36

Open DavidBarriere opened 1 year ago

DavidBarriere commented 1 year ago

Hi, I try to use d3blocks to embellish my work. But I ave an error when I try to import it to a jupyter notebook Could you help me to debugg ?

D

import os from d3blocks import D3Blocks from IPython.display import IFrame d3 = D3Blocks() df = d3.import_example('energy') d3.chord(df)


TypeError Traceback (most recent call last) Input In [8], in <cell line: 3>() 1 # Load d3blocks 2 import os ----> 3 from d3blocks import D3Blocks 4 from IPython.display import IFrame 5 # Initialize

File ~/.local/lib/python3.8/site-packages/d3blocks/init.py:1, in ----> 1 from d3blocks.d3blocks import D3Blocks 3 from d3blocks.utils import ( 4 normalize, 5 ) 7 author = 'Erdogan Taskesen, Oliver Verver'

File ~/.local/lib/python3.8/site-packages/d3blocks/d3blocks.py:15, in 13 import time 14 from typing import List, Union, Tuple ---> 15 from elasticgraph import Elasticgraph 16 import d3graph as d3network 18 import d3blocks.movingbubbles.Movingbubbles as Movingbubbles

File ~/.local/lib/python3.8/site-packages/elasticgraph/init.py:5, in 2 """Documentation about elasticgraph""" 4 import logging ----> 5 from elasticgraph.elasticgraph import Elasticgraph 7 logging.getLogger(name).addHandler(logging.NullHandler()) 9 author = "RWS Datalab"

File ~/.local/lib/python3.8/site-packages/elasticgraph/elasticgraph.py:7, in 5 from pathlib import Path 6 from typing import List, Union, Tuple ----> 7 from d3graph import d3graph, json_create, data_checks, make_graph 8 from jinja2 import Environment, PackageLoader 10 logger = logging.getLogger('')

File ~/.local/lib/python3.8/site-packages/d3graph/init.py:1, in ----> 1 from d3graph.d3graph import d3graph 2 from packaging import version 4 from d3graph.d3graph import ( 5 vec2adjmat, 6 adjmat2vec, (...) 10 data_checks, 11 )

File ~/.local/lib/python3.8/site-packages/d3graph/d3graph.py:878, in 863 return dumps(data, separators=(',', ':')) 866 # %% Convert adjacency matrix to vector 867 def adjmat2dict(adjmat: pd.DataFrame, 868 filter_weight: float = 0.0, 869 scaler: str = 'zscore', 870 marker_start=None, 871 marker_end='arrow', 872 marker_color='#808080', 873 label=None, 874 label_color='#808080', 875 label_fontsize: int = 8, 876 edge_weight: int = 1, 877 edge_distance: int = 50, --> 878 minmax: list[float] = [0.5, 15], 879 minmax_distance: list[float] = [50, 100], 880 ) -> dict: 881 """Convert adjacency matrix into vector with source and target. 882 883 Parameters (...) 934 935 """ 936 # Convert adjacency matrix into vector

TypeError: 'type' object is not subscriptable

erdogant commented 1 year ago

Seems similar to #30 Have you checked that one?

DavidBarriere commented 1 year ago

Yes I did. I added : "from typing import List, Union, Tuple from d3blocks import D3Blocks"

but error is still the same : File ~/.local/lib/python3.8/site-packages/d3graph/d3graph.py:878, in 863 return dumps(data, separators=(',', ':')) 866 # %% Convert adjacency matrix to vector 867 def adjmat2dict(adjmat: pd.DataFrame, 868 filter_weight: float = 0.0, 869 scaler: str = 'zscore', 870 marker_start=None, 871 marker_end='arrow', 872 marker_color='#808080', 873 label=None, 874 label_color='#808080', 875 label_fontsize: int = 8, 876 edge_weight: int = 1, 877 edge_distance: int = 50, --> 878 minmax: list[float] = [0.5, 15], 879 minmax_distance: list[float] = [50, 100], 880 ) -> dict: 881 """Convert adjacency matrix into vector with source and target. 882 883 Parameters (...) 934 935 """ 936 # Convert adjacency matrix into vector

TypeError: 'type' object is not subscriptable

oliver3 commented 1 year ago

Hi David,

Could it be that you are using an older version of Python like in the similar issue https://github.com/d3blocks/d3blocks/issues/34 ?

oliver3 commented 1 year ago

Oh actually, I see in your output that you are using 3.8 😅, is it possible for you to upgrade to a more recent version?

DavidBarriere commented 1 year ago

I tried, but a lot of dependencies are broken and/or need upgrade (numpy/pytorch/nilearn/jupyter) on my setup. If a version of d3blocks works on 3.8 I am interested. ;)

theano2241 commented 1 year ago

Hello :) I'm having exactly the same problem. Did you find a way to fix it?