I am trying to follow the pyvis and network tutorial and I am experiencing a rendering issue:
Traceback (most recent call last):
File ~\anaconda3\envs\needle\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\riskvm_user\documents\python scripts\needle\test1.py:36
got_net.show("gameofthrones.html")
File ~\anaconda3\envs\needle\Lib\site-packages\pyvis\network.py:546 in show
self.write_html(name, open_browser=False,notebook=True)
File ~\anaconda3\envs\needle\Lib\site-packages\pyvis\network.py:515 in write_html
self.html = self.generate_html(notebook=notebook)
File ~\anaconda3\envs\needle\Lib\site-packages\pyvis\network.py:479 in generate_html
self.html = template.render(height=height,
AttributeError: 'NoneType' object has no attribute 'render'
I have tried reinstalling pyvis, and restarting my kernel. But I can't seem to see what the issue is. I haven't altered the code at all from the tutorial. And when I just try to make a basic graph I still am unable to save the graph file as an html.
Here is my code:
from pyvis.network import Network
import pandas as pd
got_net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white")
# set the physics layout of the network
got_net.barnes_hut()
got_data = pd.read_csv("stormofswords.csv")
sources = got_data['Source']
targets = got_data['Target']
weights = got_data['Weight']
edge_data = zip(sources, targets, weights)
for e in edge_data:
src = e[0]
dst = e[1]
w = e[2]
got_net.add_node(src, src, title=src)
got_net.add_node(dst, dst, title=dst)
got_net.add_edge(src, dst, value=w)
neighbor_map = got_net.get_adj_list()
# add neighbor data to node hover data
for node in got_net.nodes:
node["title"] += " Neighbors:<br>" + "<br>".join(neighbor_map[node["id"]])
node["value"] = len(neighbor_map[node["id"]])
print(got_net.nodes)
got_net.show("gameofthrones.html")
Nevermind, I found this post on the developers GitHub page: https://github.com/WestHealth/pyvis/issues/260
I needed to downgrade my version of pyvis