Save and export options to hide inputs are unavailable in nbconvert V7.16
Closed this issue · 2 comments
thisisapple commented
thisisapple commented
I got a simple workaround for this issue. Open terminal and enter this command:
jupyter nbconvert --to html --no-input your_notebook.ipynb
You should get a html file with the same name.
thisisapple commented
There is another solution. You can write a custom function. Save the function in the same folder and import the py file into your notebook. At the end of the notebook, you can call the function to export the notebook. Below is an example.
import subprocess
import os
def export_notebook(input_path, output_path, format='html'):
if format not in ['html', 'pdf']:
raise ValueError("Format must be either 'html' or 'pdf'")
to_format = f'--to {format}'
no_input_flag = '--no-input'
command = f'jupyter nbconvert {to_format} {no_input_flag} --output {os.path.splitext(output_path)[0]} {input_path}'
try:
subprocess.run(command, shell=True, check=True)
print(f"Notebook successfully exported to {output_path}")
except subprocess.CalledProcessError as e:
print(f"An error occurred while exporting the notebook: {e}")
print(e.output)