jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.75k stars 568 forks source link

from python cmd running update ipynb file, then export to html, errors pops up #1765

Open kk120120 opened 2 years ago

kk120120 commented 2 years ago

Hi, I want to create a cmd lines to be scheduled to update/run the ipynb file, then export to html without input. in first step, update the notebook output has problem.

below are codes of command and the lib versions. Thanks for help!

Best Regards, Kevin

PS D:\WPy64-3970b3\notebooks\myWork> jupyter nbconvert --execute --to notebook --inplace D:\WPy64-3970b3\notebooks\myWork\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb --ExecutePreprocessor.kernel_name=python3

another command has same errors

jupyter nbconvert --execute D:\WPy64-3970b3\notebooks\myWork\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb --to=html --no-input --output="C:\Users\hanzhanwen\Desktop\IAM_1-2-3project_overview_2022-04-25"
import os
import datetime as dt

cmd = f'jupyter nbconvert --execute D:\\WPy64-3970b3\\notebooks\\myWork\\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb --to=html --no-input --output="C:\\Users\\x_local\\Desktop\\IAM_1-2-3project_overview_{dt.datetime.today().strftime("%Y-%m-%d")}"'

# cmd = f'jupyter nbconvert --execute --to notebook --inplace D:\\WPy64-3970b3\\notebooks\\myWork\\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb '
# cmd = 'jupyter nbconvert --execute --to notebook --inplace D:\\WPy64-3970b3\\notebooks\\myWork\\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb --ExecutePreprocessor.kernel_name=python3'
print(cmd)
os.system(cmd)

winPython portable envrionment Python 3.9

Name: nbconvert Version: 5.6.1 Summary: Converting Jupyter Notebooks Home-page: https://jupyter.org Author: Jupyter Development Team Author-email: jupyter@googlegroups.com License: BSD Location: d:\wpy64-3970b3\python-3.9.7.amd64\lib\site-packages

Name: jupyterlab Version: 3.2.1 Summary: JupyterLab computational environment Home-page: https://jupyter.org Author: Jupyter Development Team Author-email: jupyter@googlegroups.com License: UNKNOWN Location: d:\wpy64-3970b3\python-3.9.7.amd64\lib\site-packages

output: [NbConvertApp] WARNING | Config option template_path not recognized by NotebookExporter. [NbConvertApp] Converting notebook D:\WPy64-3970b3\notebooks\myWork\1-2-3processMonthlyReview_detail_YYYYMM_juliet.ipynb to notebook D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\zmq_future.py:591: RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zm q. Registering an additional selector thread for add_reader support via tornado. Use asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()) to avoid this warning . self._get_loop() [NbConvertApp] Executing notebook with kernel: python3 Traceback (most recent call last): File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\WPy64-3970b3\python-3.9.7.amd64\Scripts\jupyter-nbconvert.EXE__main.py", line 7, in File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\jupyter_core\application.py", line 264, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, kwargs) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\traitlets\config\application.py", line 846, in launch_instance app.start() File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\nbconvertapp.py", line 340, in start self.convert_notebooks() File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\nbconvertapp.py", line 510, in convert_notebooks self.convert_single_notebook(notebook_filename) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\nbconvertapp.py", line 481, in convert_single_notebook output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\nbconvertapp.py", line 410, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\exporters\exporter.py", line 179, in from_filename return self.from_file(f, resources=resources, kw) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\exporters\exporter.py", line 197, in from_file return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, kw) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\exporters\notebook.py", line 32, in from_notebook_node nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, kw) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\exporters\exporter.py", line 139, in from_notebook_node nb_copy, resources = self._preprocess(nb_copy, resources) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\exporters\exporter.py", line 316, in _preprocess nbc, resc = preprocessor(nbc, resc) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in call__ return self.preprocess(nb, resources) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\execute.py", line 405, in preprocess nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess nb.cells[index], resources = self.preprocess_cell(cell, resources, index) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\execute.py", line 438, in preprocess_cell reply, outputs = self.run_cell(cell, cell_index, store_history) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\execute.py", line 578, in run_cell exec_reply = self._poll_for_reply(parent_msg_id, cell, timeout) File "D:\WPy64-3970b3\python-3.9.7.amd64\lib\site-packages\nbconvert\preprocessors\execute.py", line 479, in _poll_for_reply if msg['parent_header'].get('msg_id') == msg_id: TypeError: 'coroutine' object is not subscriptable sys:1: RuntimeWarning: coroutine 'ZMQSocketChannel.get_msg' was never awaited

d-kleine commented 2 years ago

Have you checked this already?