1

I want to convert a jupyter notebook to a clean python file.

I don't want the # In[ ]: comments in the generated python script, I want it to be clean.

Is there any way to do that?

I ran below command jupyter nbconvert --to script --no-prompt notebook.ipynb as mentioned in the comments of this answer but the generated script still contains # In[ ]: comments.

Generated script:

#!/usr/bin/env python
# coding: utf-8

# In[1]:


print("Hello World")


# In[2]:


print("Hello Jupyter")

Desired script:

#!/usr/bin/env python
# coding: utf-8

print("Hello World")

print("Hello Jupyter")
naman
  • 482
  • 4
  • 10
  • 1
    what is the error? – vb_rises Aug 19 '19 at 12:54
  • @Vishal There is no error. I am looking for a command to quickly generate a clean python script without `# In[ ]:` comments and its spacing according to [PEP 8](https://www.python.org/dev/peps/pep-0008/). Both GUI and the command mentioned in the question do not give a clean script. – naman Aug 20 '19 at 05:19
  • I tried with mine, and everything was clean. – N. Arunoprayoch Aug 20 '19 at 06:21

0 Answers0