This repository contains a Python script (convert_ipynb_to_docx.py) that automates the conversion of all Jupyter Notebook (.ipynb) files in the current directory into Word documents (.docx).
Before running the script, make sure you have the following installed:
-
Python (3.7 or newer)
-
Jupyter Notebook
- Install Jupyter Notebook using
pip:pip install notebook
- Install Jupyter Notebook using
-
Pandoc
- Download and install Pandoc from https://pandoc.org/installing.html.
- Ensure Pandoc is added to your system's
PATHso it can be used from the terminal. - Add the install location in yout system's
PATHits usuallyC:\Program Files\Pandoc\pandoc.exe
Follow these steps to use the script:
-
Clone the Repository Clone this repository to your local machine:
git clone <repository_url> cd <repository_name>
- Install Required Python Libraries
Install the
nbconvertpackage, which is used for converting.ipynbto.md:
pip install nbconvert
- Install Required Python Libraries
Install the
-
Place the Jupyter Notebooks in the Directory Ensure all the
.ipynbfiles you want to convert are in the same directory as the script (convert_ipynb_to_docx.py). -
Run the Script Run the script from the terminal:
python convert_ipynb_to_docx.py
-
View the Output
- The script will generate
.docxfiles for each.ipynbfile in the current directory. - The
.docxfiles will be saved in the same directory as the script.
- The script will generate
-
Clean Up (Optional)
- The script automatically removes intermediate
.mdfiles after the conversion. - If you want to keep the
.mdfiles, edit the script and comment out theos.remove(md_file)line.
- The script automatically removes intermediate
Suppose your directory contains the following files:
convert_ipynb_to_docx.py
notebook1.ipynb
notebook2.ipynb
After running the script, your directory will look like this:
convert_ipynb_to_docx.py
notebook1.ipynb
notebook2.ipynb
notebook1.docx
notebook2.docx
-
Command not found: pandoc
- Ensure Pandoc is installed and added to your system's
PATH. - You can test this by running:
pandoc --version
- Ensure Pandoc is installed and added to your system's
-
Missing Jupyter or nbconvert
- Ensure Jupyter is installed using:
pip install notebook
- Ensure Jupyter is installed using:
-
Script Errors
- Make sure your
.ipynbfiles are not corrupted or empty. - If you encounter specific errors, please open an issue in this repository.
- Make sure your
Happy converting!