From 91a01e32f7ed343bb35b49d02c05fca228d25245 Mon Sep 17 00:00:00 2001 From: Alexey Biryukov Date: Thu, 6 Apr 2023 14:33:40 +0300 Subject: [PATCH] Update network.py force html writing encoding to utf-8, to fix 'UnicodeDecodeError: 'charmap' codec can't decode' --- pyvis/network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyvis/network.py b/pyvis/network.py index 8deb915..d7b6727 100644 --- a/pyvis/network.py +++ b/pyvis/network.py @@ -523,10 +523,10 @@ def write_html(self, name, local=True, notebook=False,open_browser=False): shutil.copytree(f"{os.path.dirname(__file__)}/templates/lib/tom-select", "lib/tom-select") if not os.path.exists(os.getcwd()+"/lib/vis-9.1.2"): shutil.copytree(f"{os.path.dirname(__file__)}/templates/lib/vis-9.1.2", "lib/vis-9.1.2") - with open(getcwd_name, "w+") as out: + with open(getcwd_name, "w+", encoding='utf8') as out: out.write(self.html) elif self.cdn_resources == "in_line" or self.cdn_resources == "remote": - with open(getcwd_name, "w+") as out: + with open(getcwd_name, "w+", encoding='utf8') as out: out.write(self.html) else: assert "cdn_resources is not in ['in_line','remote','local']."