treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
179 stars 18 forks source link

`ModuleNotFoundError: No module named 'ipython_genutils'` #102

Open yasirroni opened 1 year ago

yasirroni commented 1 year ago

Describe the bug In a rare case, an error might happen due to ipython_genutils not properly installed. That is because nbmake did not require ipython_genutils nor jupyter explicitly. Others also get this behavior while using IPython https://github.com/ipython/ipython_genutils/issues/3.

On my use case, the error happen on matpower-pip workflow and fixed with a commit https://github.com/yasirroni/matpower-pip/commit/ae73edf2fa4e2def772a5863a918b099c63ff545

To Reproduce I don't know exactly how to reproduce, but install nbmake seems not installing ipython_genutils

Expected behavior Whenever someone using nbmake, we can assume that they are going to test IPython file. Then, isn't logical to make nbmake require at least jupyter?

Screenshots

Desktop (please complete the following information):


If not installing jupyter by default is the expected behavior, please ignore and close this issue.

alex-treebeard commented 1 year ago

thanks for the report @yasirroni

I need to look a bit further but it's likely this is caused by a combination of pkg version.

See the source repo: https://github.com/ipython/ipython_genutils

It implies we shouldn't be depending on it, so let's try figure out how to resolve this issue without adding the dependency.

yasirroni commented 1 year ago

On my use case, simply adding jupyter as dependency solve the issue.

yasirroni commented 1 year ago

Another issue

NBMAKE INTERNAL ERROR
Kernel died before replying to kernel_info

...

ImportError: cannot import name 'write_connection_file' from 'jupyter_client' (/opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/jupyter_client/__init__.py)

See https://github.com/yasirroni/matpower-pip/actions/runs/4355686258/jobs/7627873484

yasirroni commented 1 year ago

After some digging, it seems that the bug might be from a cell containing !pip install SOMETHING==... that cause incompatibility of Jupyter. Solved using os.sytem() approach that detect the version used by the environment (thus, avoiding reinstallation that might cause a bug).

alex-treebeard commented 1 year ago

thanks for the follow up @yasirroni , think I'll leave this one open as a bug for now, given that we should be eliminating internal errors (in favour of something more helpful)

yasirroni commented 1 year ago

Sure. This kind of bug is pretty silent and challenging to solve! Hope you can catch this error and return a proper message for user.