Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To convert a Jupyter Notebook to nbconvert without using magic commands or markdown, you can use the following steps:

  1. Open your Jupyter Notebook in a code editor.
  2. Remove any magic commands and markdown cells from your code, leaving only the Python code.
  3. Save the modified notebook.
  4. Open a terminal window and navigate to the directory containing the Jupyter Notebook file.
  5. Type the command jupyter nbconvert --to=python <notebook-name>.ipynb, replacing <notebook-name> with the name of your notebook file (without the .ipynb extension).
  6. Press Enter to execute the command. This will create a new .py file in the same directory as your original notebook file.
  7. You can optionally edit this .py file to make any final modifications before using it as desired.

Note that if your notebook contains any non-Python code (such as SQL or R), you will need to modify it accordingly to ensure that it can be properly converted to a .py file.