Skip to main content

Convert .py files runnable in VSCode/Python or Atom/Hydrogen to jupyter/colab .ipynb notebooks and vice versa

Project description

colab-convert

Atom/Hydrogen or VSCode/Python allows creating a python files split into cells with # %% separators with the ability to run cells via backend Jupyter session and interactively show results back.

More examples: Jupyter Python VSCode examples, Atom/Hydrogen Getting Started.

colab-convert python module converts files: .ipynb to .py and .py to .ipynb.

colab-convert is a fork of the ipynb-py-convert.

Install

conda install -c defaults -c conda-forge colab-convert

or

pip install colab-convert

Troubleshooting

  • If encoding problems on Windows try using python>=3.7, setting set PYTHONUTF8=1 in Windows console and use colab-convert for UTF-8 files only. If using Git-Bash on Windows setting:
export LANG=C.UTF-8
export PYTHONIOENCODING=utf-8
export PYTHONUTF8=1

should be enough. Also try setting default Bash settings to UTF-8: [Options] - [Text] - [Locale / Character set] - [C / UTF-8]. It might affect all Bash runs so there would be no need to setting encoding every time.

Example

colab-convert examples/plot.py examples/plot.ipynb

or

colab-convert examples/plot.ipynb examples/plot.py

VSCode

Markdown cells are converted to python multiline strings '''. Code cells are left as is. # %% is used by vscode as the cell marker on which 'Run Cell' action is available.

Metadata is converted from notebooks into .py and vise versa using # !! to denote the meta data lines in the .py files

Jupyter ipynb notebook

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colab-convert-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file colab-convert-1.0.1.tar.gz.

File metadata

  • Download URL: colab-convert-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for colab-convert-1.0.1.tar.gz
Algorithm Hash digest
SHA256 79036fe1f922207f7a568e45e040400ed0c4b4b59c1a71e41b4fd7044fd30c64
MD5 9f351b4de16896e3add0f9bc5410fc1f
BLAKE2b-256 8fc42c1c3565b58593197cdca3e2e4d91619e58f7463531a6048dff10131227d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page