Converting notebook to HTML throws encoding error on windows
See original GitHub issue====================================================== DAG build failed ======================================================
----- NotebookRunner: fit -> MetaProduct({'model': File('products\\model.pickle'), 'nb': File('products\\report.html')}) -----
----------------------------------------- C:\Users\edubl\Desktop\proj\scripts\fit.py -----------------------------------------
Traceback (most recent call last):
File "c:\users\edubl\desktop\proj\venv-proj\lib\site-packages\ploomber\tasks\abc.py", line 562, in _build
res = self._run()
File "c:\users\edubl\desktop\proj\venv-proj\lib\site-packages\ploomber\tasks\abc.py", line 669, in _run
self.run()
File "c:\users\edubl\desktop\proj\venv-proj\lib\site-packages\ploomber\tasks\notebook.py", line 525, in run
self._converter.convert()
File "c:\users\edubl\desktop\proj\venv-proj\lib\site-packages\ploomber\tasks\notebook.py", line 94, in convert
self._from_ipynb(self.path_to_output, self.exporter,
File "c:\users\edubl\desktop\proj\venv-proj\lib\site-packages\ploomber\tasks\notebook.py", line 160, in _from_ipynb
path.write_text(content)
File "C:\Users\edubl\miniconda3\envs\scaffold\lib\pathlib.py", line 1256, in write_text
return f.write(data)
File "C:\Users\edubl\miniconda3\envs\scaffold\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\ue6c6' in position 233857: character maps to <undefined>
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Non-ASCII character in notebook - windows - Stack Overflow
I have a notebook that i want to convert to html using nbconvert. When i start the conversion, it throws this exception: "'utf-8'...
Read more >Cannot export python notebook to ipython notebook or html ...
I edited a python notebook in databricks and I'd like to export it as ipython notebook or html file. However, I got the...
Read more >nbconvert Documentation - Read the Docs
For converting notebooks to PDF with --to webpdf, nbconvert requires the Pyppeteer Chromium automation library.
Read more >How can I fix the UTF-8 error when bulk uploading users?
This error occurs because the software you are using saves the file in a different type of encoding, such as ISO-8859, instead of...
Read more >IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Dict of functions for converting values in certain columns. Keys can either be integers or column labels. true_valueslist, default None. Values to consider...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to reproduce this error on two independent windows machines (both win 10 and 11).
ploomber examples -n templates/ml-basic -o ml-basic
pipeline.yaml
file to conver only one filetasks: - source: Readme.ipynb product: Readme.md
ploomber build
outputs very similar message (the file Readme.ipynb comes with utf-8 encoding, though looks like cp1252 attempted)ploomber build
maybe
ploomber nb -i
output can also help:As I am using python 3, I strongly believe it is connected with relying on utf-8 as system default encoding as described here. It can be easily solved with adding
encoding='utf-8'
parameter to the file.open function. As I do not know the tool’s structure, I am a bit lost on where the actual read happens.Hey @kubow, I’m working on a final solution to the encoding problem. Which Windows and Python version are you running? I’d like to test the new implementation.
Also, I found out that the graphviz team is simplifying installation on windows. You may want to check it out.