drivendataorg / nbautoexport

Automatically export Jupyter notebooks to various file formats (.py, .html, and more) on save.
https://nbautoexport.drivendata.org/
MIT License
72 stars 9 forks source link

notebook.services replaced in notebook version 7.0.0 #121

Closed JnCoe closed 1 year ago

JnCoe commented 1 year ago

Description

When running nbautoexport install I got the following error:

Traceback (most recent call last): File "/home/jonas/myspace/bin/nbautoexport", line 5, in from nbautoexport.nbautoexport import app File "/home/jonas/myspace/lib/python3.10/site-packages/nbautoexport/init.py", line 1, in from nbautoexport.export import post_save File "/home/jonas/myspace/lib/python3.10/site-packages/nbautoexport/export.py", line 6, in from notebook.services.contents.filemanager import FileContentsManager ModuleNotFoundError: No module named 'notebook.services'

What I Did

notebook.services seem to have been replaced by _jupyterserver.services in notebook version 7.0.0. I first uninstalled then reinstalled notebook using pip install notebook==6.5.4 and ran nbautoexport install again. This time, it worked, printing the message below and successfully converting a .ipynb file automatically when I tested it later:

nbautoexport post-save hook successfully installed with Jupyter. If a Jupyter server is already running, you will need to restart it for nbautoexport to work.

Additionally, I reverted back to version 7.0.0 and made an edit in the nbautoexport/export.py file. I replaced the line from notebook.services.contents.filemanager import FileContentsManager with from jupyter_server.services.contents.filemanager import FileContentsManager. After making this change, I ran nbautoexport install again, and it worked as expected, displaying the same success message and successfully converting the file during subsequent testing.

I'm not sure about the consequences of modifying this particular line of code, but for now, I haven't encountered any noticeable issues.

jayqi commented 1 year ago

Closed by #122, released as v0.5.2