llama_index
llama_index copied to clipboard
Error: 'charmap' codec can't encode characters in position
Hi I am running the Knowledge graph example on windows. When trying to visualize I get the following error. Would appreciate your help in getting it to run. Thanks
UnicodeEncodeError Traceback (most recent call last) Cell In[34], line 8 6 net.from_nx(g) 7 #net.show("example.html")#.encode('utf-8') ----> 8 net.save_graph("example.html")
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvis\network.py:435, in Network.save_graph(self, name) 428 """ 429 Save the graph as html in the current directory with name. 430 431 :param name: the name of the html file to save as 432 :type name: str 433 """ 434 check_html(name) --> 435 self.write_html(name)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvis\network.py:508, in Network.write_html(self, name, local, notebook) 505 self.html = self.generate_html(notebook=notebook) 507 with open(name, "w+") as out: --> 508 out.write(self.html) 510 if notebook: 511 with open(name, "w+") as out:
File ~\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py:19, in IncrementalEncoder.encode(self, input, final) 18 def encode(self, input, final=False): ---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 263607-263621: character maps to
same here:
UnicodeEncodeError Traceback (most recent call last) Cell In[27], line 7 5 net = Network(notebook=True, cdn_resources="in_line", directed=True) 6 net.from_nx(g) ----> 7 net.show("example.html")
File c:\Python311\Lib\site-packages\pyvis\network.py:549, in Network.show(self, name, local) 547 check_html(name) 548 if self.template is not None: --> 549 return self.write_html(name, local, notebook=True) 550 else: 551 self.write_html(name, local)
File c:\Python311\Lib\site-packages\pyvis\network.py:508, in Network.write_html(self, name, local, notebook) 505 self.html = self.generate_html(notebook=notebook) 507 with open(name, "w+") as out: --> 508 out.write(self.html) 510 if notebook: 511 with open(name, "w+") as out:
File c:\Python311\Lib\encodings\cp1252.py:19, in IncrementalEncoder.encode(self, input, final) 18 def encode(self, input, final=False): ---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 263607-263621: character maps to
Open c:\Python311\Lib\site-packages\pyvis\network.py
Find line 507, change from with open(name, "w+") as out: to with open(name, "w+", encoding="utf-8") as out:
thanks for flagging! apologies for the delay. will take a look soon
Closing old issues, looks like it's specific to pyvis