{"id":26232549,"url":"https://github.com/bulletmark/nbtopy","last_synced_at":"2025-07-19T13:33:56.901Z","repository":{"id":62015829,"uuid":"557107326","full_name":"bulletmark/nbtopy","owner":"bulletmark","description":"Converts Jupyter notebook files to Python files","archived":false,"fork":false,"pushed_at":"2025-01-27T23:22:01.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T12:05:23.588Z","etag":null,"topics":["jupyter","nbconvert","notebook","vscode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bulletmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-25T04:53:35.000Z","updated_at":"2025-01-27T23:22:04.000Z","dependencies_parsed_at":"2024-11-15T05:34:53.666Z","dependency_job_id":null,"html_url":"https://github.com/bulletmark/nbtopy","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"32457bc798969c62595cbab724ec288bdd767d7f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fnbtopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fnbtopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fnbtopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fnbtopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bulletmark","download_url":"https://codeload.github.com/bulletmark/nbtopy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250222113,"owners_count":21394818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter","nbconvert","notebook","vscode"],"created_at":"2025-03-13T00:37:28.370Z","updated_at":"2025-07-19T13:33:56.880Z","avatar_url":"https://github.com/bulletmark.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NBTOPY - Converts Jupyter notebook files to Python files\n[![PyPi](https://img.shields.io/pypi/v/nbtopy)](https://pypi.org/project/nbtopy/)\n[![AUR](https://img.shields.io/aur/version/nbtopy)](https://aur.archlinux.org/packages/nbtopy/)\n\n[nbtopy](http://github.com/bulletmark/nbtopy) is a Linux command line\nutility to convert one or more [Jupyter](https://jupyter.org/) notebook\nfiles (`.ipynb`) to Python files (`.py`). My primary purpose for\ncreating this utility is to quickly and easily create Python files to\nuse with the superb [Python\nInteractive](https://code.visualstudio.com/docs/python/jupyter-support-py)\nmode in [Visual Studio Code](https://code.visualstudio.com/), which I\noften prefer to use instead of the Jupyter notebook. In the generated\ncode, Python code blocks are delimited by `# %%` tags and markdown\nblocks are delimited by `# %% [markdown]` tags.\n\nA typical use case is when you download a directory of Jupyter notebook\nfiles and want run them using a VS Code [Python\nInteractive](https://code.visualstudio.com/docs/python/jupyter-support-py)\nwindow. Just run `nbtopy .` in the directory and all the Python files\nare created and ready to use. You could use VS Code's inbuilt command to\ncreate a Python file from the notebook but that is slow and awkward\nbecause you have to run it explicitly for each notebook, and then\nmanually rename each created file. Also, VS Code uses Jupyter's\n[`nbconvert`](https://nbconvert.readthedocs.io/) tool to do the\nconversion and that runs *much* slower than `nbtopy`.\n\nThis program uses only pure Python and does not require any\n[Jupyter](https://jupyter.org/) or 3rd party software or utilities to be\ninstalled.\n\n### Examples\n\n1. Convert single `myfile.ipynb` file to new `myfile.py`:\n\n    ```\n    $ nbtopy myfile.ipynb\n    ```\n\n2. Convert all `*.ipynb` files in current directory to `*.py`:\n\n    ```\n    $ nbtopy . (effectively same as nbtopy *.ipynb)\n    ```\n\n3. Write all `*.py` files to directory `pyfiles/` instead of current dir:\n\n    ```\n    $ nbtopy -d pyfiles .\n    ```\n\n4. Recurse through all child directories and write `*.py` files to\n   directory `pyfiles/` in same directories as source `**/*.ipynb`\n   files.\n\n    ```\n    $ nbtopy -r -d pyfiles .\n    ```\n\n5. Recurse through all child directories and write `*.py` files to new\n   and independent tree rooted under `pyfiles/`. Specify this by using\n   an absolute (rather than relative) path for `-d/--dir`.\n\n    ```\n    $ nbtopy -r -d $PWD/pyfiles .\n    ```\n\n## Installation or Upgrade\n\nArch users can install [nbtopy from the\nAUR](https://aur.archlinux.org/packages/nbtopy/).\n\nPython 3.6 or later is required. Note [nbtopy is on\nPyPI](https://pypi.org/project/nbtopy/) so just ensure that\n[`pipx`](https://pipx.pypa.io/stable/) is installed then type the\nfollowing:\n\n```\n$ pipx install nbtopy\n```\n\nTo upgrade:\n\n```\n$ pipx upgrade nbtopy\n```\n\nThis program runs on pure Python. No 3rd party packages are required.\nNote that this program does not require Jupyter's\n[nbconvert](https://nbconvert.readthedocs.io/) tool.\n\n## Command Line Options\n\nType `nbtopy -h` to view the usage summary:\n\n```\nusage: nbtopy [-h] [-m] [-M] [-c] [-e] [-x] [-f] [-r] [-p] [-q] [-w]\n                 [-o OUT] [-d DIR] [-V]\n                 [ipynb_path ...]\n\nConverts Jupyter notebook file[s] to Python (interactive) file[s].\n\npositional arguments:\n  ipynb_path            input ipynb file[s] (or dir for all *.ipynb files)\n\noptions:\n  -h, --help            show this help message and exit\n  -m, --no-markdown-tag\n                        do not add markdown tag on markdown cells\n  -M, --no-markdown     do not output markdown cells at all\n  -c, --no-code-tag     do not add code tag on code cells\n  -e, --include-empty   include empty/blank cells in output\n  -x, --exclude-no-code\n                        skip file if it contains no Python code cells\n  -f, --force           force overwrite existing file[s]\n  -r, --recurse         recursively process files in all sub-directories\n  -p, --purge           just purge associated output file[s]\n  -q, --quiet           suppress messages about processed file[s]\n  -w, --no-warnings     suppress warning messages about processed file[s]\n  -o OUT, --out OUT     alternative output file name, or '-' for stdout\n  -d DIR, --dir DIR     output directory, default = \".\". Specify absolute path\n                        to create separate tree of output files\n  -V, --version         show nbtopy version\n\nNote you can set default options in ~/.config/nbtopy-flags.conf.\n```\n\n## Default Options\n\nYou can add default options to a personal configuration file\n`~/.config/nbtopy-flags.conf`. If that file exists then each line of\noptions will be concatenated and automatically prepended to your\n`nbtopy` command line options. Type `nbtopy -h` to see the options\nsupported.\n\nE.g. in your `~/.config/nbtopy-flags.conf` you could have the line\n`--no-markdown-tag` so that markdown cells are always merely aded as\ncomments, without an explicit markdown tag.\n\n## License\n\nCopyright (C) 2022 Mark Blakeney. This program is distributed under the\nterms of the GNU General Public License. This program is free software:\nyou can redistribute it and/or modify it under the terms of the GNU\nGeneral Public License as published by the Free Software Foundation,\neither version 3 of the License, or any later version. This program is\ndistributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at\n\u003chttp://www.gnu.org/licenses/\u003e for more details.\n\n\u003c!-- vim: se ai syn=markdown: --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbulletmark%2Fnbtopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbulletmark%2Fnbtopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbulletmark%2Fnbtopy/lists"}