treebeardtech / nbmake

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

`pip install nbmake` breaks pytest with `ModuleNotFoundError: No module named 'ipython_genutils'` #63

Closed cisaacstern closed 2 years ago

cisaacstern commented 2 years ago

Describe the bug Installing nbmake with pip appears to break the command line invocation of pytest with ModuleNotFoundError: No module named 'ipython_genutils'.

To Reproduce Steps to reproduce the behavior:

1. Create and activate a new virtual environment

$ python3 -m venv ./nbmake
$ source ./nbmake/bin/activate
(nbmake) $

2. Install pytest and nbmake

(nbmake) $ python3 -m pip install pytest nbmake -q
(nbmake) $ pip list
output of pip list ``` Package Version ------------------- ------- appnope 0.1.2 asttokens 2.0.5 attrs 21.4.0 backcall 0.2.0 debugpy 1.5.1 decorator 5.1.1 entrypoints 0.4 executing 0.8.3 importlib-resources 5.4.0 iniconfig 1.1.1 ipykernel 6.9.1 ipython 8.1.1 jedi 0.18.1 jsonschema 4.4.0 jupyter-client 7.1.2 jupyter-core 4.9.2 matplotlib-inline 0.1.3 nbclient 0.5.12 nbformat 5.2.0 nbmake 1.2 nest-asyncio 1.5.4 packaging 21.3 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 pip 20.2.3 pluggy 1.0.0 prompt-toolkit 3.0.28 ptyprocess 0.7.0 pure-eval 0.2.2 py 1.11.0 pydantic 1.9.0 Pygments 2.11.2 pyparsing 3.0.7 pyrsistent 0.18.1 pytest 7.0.1 python-dateutil 2.8.2 pyzmq 22.3.0 setuptools 49.2.1 six 1.16.0 stack-data 0.2.0 tomli 2.0.1 tornado 6.1 traitlets 5.1.1 typing-extensions 4.1.1 wcwidth 0.2.5 zipp 3.7.0 ```

3. Call pytest which raises

(nbmake) $ pytest
Traceback (most recent call last):
  File "/nbmake/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/nbmake/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/nbmake/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/nbmake/lib/python3.8/site-packages/pluggy/_callers.py", line 55, in _multicall
    gen.send(outcome)
  File "/nbmake/lib/python3.8/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/nbmake/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/nbmake/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "/nbmake/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1172, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/nbmake/lib/python3.8/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/nbmake/lib/python3.8/site-packages/nbmake/pytest_plugin.py", line 6, in <module>
    from .pytest_items import NotebookFile
  File "/nbmake/lib/python3.8/site-packages/nbmake/pytest_items.py", line 14, in <module>
    from .nb_run import NotebookRun
  File "/nbmake/lib/python3.8/site-packages/nbmake/nb_run.py", line 5, in <module>
    from nbclient.client import (
  File "/nbmake/lib/python3.8/site-packages/nbclient/__init__.py", line 6, in <module>
    from .client import NotebookClient, execute  # noqa: F401
  File "/nbmake/lib/python3.8/site-packages/nbclient/client.py", line 39, in <module>
    from .output_widget import OutputWidget
  File "/nbmake/lib/python3.8/site-packages/nbclient/output_widget.py", line 6, in <module>
    from .jsonutil import json_clean
  File "/nbmake/lib/python3.8/site-packages/nbclient/jsonutil.py", line 16, in <module>
    from ipython_genutils import py3compat
ModuleNotFoundError: No module named 'ipython_genutils'

Expected behavior I would expect installing nbmake via pip to not break pytest.

Screenshots n/a

Desktop (please complete the following information):

Smartphone (please complete the following information): n/a

Additional context None I can think of. Happy to answer follow up questions!

alex-treebeard commented 2 years ago

Hi @cisaacstern thanks for the report.

Looks like nbclient 0.5.12 has this issue on my end.

Please could you try pip install nbclient==0.5.13

If this fixes it then I may require this version or higher.

cisaacstern commented 2 years ago

@alex-treebeard thanks for the prompt reply.

This does solve the problem for me.

I've opened #65 for your consideration.