Orca
Orca

Reputation: 505

Python does not open default web browser to show visualization results in pyvis?

In one part of my code, I need to visualize the generate graph using pyvis library. When i was using python 3.10 everything was ok and the graph was visualized in the default browser, but now due to some reasons i need to use python 3.6.4. In this situation when i generate graph and i want to open it in default browser (which is firefox now), it always opens Internet Explorer of windows and does not show anything and it always go to bing!, whereas my default browser is FireFox. Is there anything wrong with python 3.6.4? the code below is used to visualize. How can i open the generated graph in the default browser? I really appreciate answers which solves my problem.

palette = (sns.color_palette("Pastel1", n_colors=len(set(labelList.values()))))  
        palette = palette.as_hex()
        colorDict = {}
        counter = 0
        for i in palette:
            colorDict[counter] = i
            counter += 1

     

        N = Network(height='100%', width='100%', directed=False, notebook=False, heading = self.headerName)
        for n in G.nodes:

            N.add_node(n, color=(colorDict[labelList[n]]), size=5)
        for e in G.edges.data():
            N.add_edge(e[0], e[1])


        N.show('./result.html')

Upvotes: 3

Views: 945

Answers (2)

Mulugeta Weldezgina
Mulugeta Weldezgina

Reputation: 669

Try passing notebook=False when calling the graph.show().

N.show('./result.html', notebook=False)

It seems in the pyvis version=0.3, the graph.show() has its out notebook parameter overriding the Network()

Upvotes: 0

Federico Bindi
Federico Bindi

Reputation: 1

Happened to me as well. Now I simply insert the ".show()" method in a try-except block, and click each time on the html file generated to visualize it in Chrome (annoying, I know).

Upvotes: 0

Related Questions