betatim / notebook-as-pdf

Save Jupyter Notebooks as PDF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nbconvert failed: module 'asyncio' has no attribute 'run'

ENIAC-6 opened this issue · comments

I am on Python 3.6.9 and trying to download a Jupyter Notebook with markdown cells (containing HTML code) to PDF. I could not find a conda package version of notebook-as-pdf and so I used pip install. However, when tying to download (File > Download as > PDF via HTML (.pdf) I receive the following error: nbconvert failed: module 'asyncio' has no attribute 'run'

Also receive the following error when attempting to download via Python or Anaconda command prompt with: jupyter-nbconvert --to pdfviahtml C:\Users\myProfile\Documents\Jupyter_Notebook\Announcement\Announcement.ipynb

(arcgispro-py3) C:\Users\myProfile>jupyter-nbconvert --to pdfviahtml C:\Users\myProfile\Documents\Jupyter_Notebook\Announcement\Announcement.ipynb
Traceback (most recent call last):
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\Scripts\jupyter-nbconvert-script.py", line 10, in
sys.exit(main())
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\nbconvert\nbconvertapp.py", line 340, in start
self.convert_notebooks()
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\nbconvert\nbconvertapp.py", line 499, in convert_notebooks
cls = get_exporter(self.export_format)
File "C:\Users\myProfile\MyPrograms\ESRI_ArcGIS_Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\nbconvert\exporters\base.py", line 113, in get_exporter
% (name, ', '.join(get_export_names())))
ValueError: Unknown exporter "pdfviahtml", did you mean one of: PDFviaHTML, asciidoc, custom, html, latex, markdown, notebook, pdf, python, rst, script, slides?

I also encountered this issue when attempting to run via Python 3.6.9

Further research led me to this StackOverflow which clarified that asyncio.run was new in Python 3.7, as seen in the python documentation.

I would therefore suggest that unless supporting the latest version of the pip package on 3.6.9 is critical, the latest package should clarify that it supports 3.7 and onward.

To the person who encountered this issue, I followed the same installation procedure in Python 3.8 and I was able to create a PDF with no issues.

I know its not a fix, but hopefully this gets you running.