How to convert a python project to ipynb format notebook?

Viewed 33

I have a python machine learning project in a folder. I want to change the whole project into ipynb formate notebook. Actually I want it in Google Colab.

2 Answers

Use p2j to convert Python source code to Jupyter Notebook.

From the command line, run

pip install p2j

then go to the directory where your file is located. -->( for example-> cd downloads, if the file is in download directory)

then run

p2j myscript.py

This will create a myscript.ipynb file.

You can do the following to achieve your goal in easiest way:

  1. Compress your folder to a zip file

  2. Open google colab and create a new notebook

  3. On the left side there will be a menu, click the upload button on the upper left corner of that menu and upload the folder.

  4. User ' !unzip /path-to-file' to unzip the whole folder.

Ps: you can copy the zipped folder path by right clicking on it and it will give you a few options including 'copy path'.

Related