treebeardtech / nbmake

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

No such kernel named python3 #122

Closed rcpeene closed 6 months ago

rcpeene commented 7 months ago

Describe the bug pytest can't seem to find my basic python3 kernel. when running pytest --nbmake -n=auto ./docs/projects/illusion.ipynb the test fails and I receive No such kernel named python3

To Reproduce I am not sure what steps would be required to reproduce; I simply installed nbmake and pytest-xdist and run the above command within the local clone of my repo https://github.com/AllenInstitute/openscope_databook.git

Expected behavior I expect the test to pass

Traceback

=================================================================================================================================================================================== test session starts ====================================================================================================================================================================================
platform win32 -- Python 3.9.10, pytest-7.2.1, pluggy-1.0.0
rootdir: C:\Users\carter.peene\Desktop\Projects\openscope_databook
plugins: anyio-3.6.1, nbmake-1.5.3, cov-4.0.0, xdist-3.5.0
8 workers [1 item]      
F                                                                                                                                                                                                                                                                                                                                                                                     [100%]
========================================================================================================================================================================================= FAILURES =========================================================================================================================================================================================
__________________________________________________________________________________________________________________________________________________ C:\Users\carter.peene\Desktop\Projects\openscope_databook\docs\projects\illusion.ipynb __________________________________________________________________________________________________________________________________________________ 
[gw0] win32 -- Python 3.9.10 C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\python.exe
Error - No such kernel: 'python3'
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Captured log call ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
WARNING  traitlets:kernelspec.py:284 Kernelspec name python3 cannot be found!
ERROR    traitlets:manager.py:95 No such kernel named python3
Traceback (most recent call last):
  File "C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_client\manager.py", line 87, in wrapper
    out = await method(self, *args, **kwargs)
  File "C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_client\manager.py", line 435, in _async_start_kernel
    kernel_cmd, kw = await self._async_pre_start_kernel(**kw)
  File "C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_client\manager.py", line 397, in _async_pre_start_kernel
    self.kernel_spec,
  File "C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_client\manager.py", line 195, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "C:\Users\carter.peene\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_client\kernelspec.py", line 285, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named python3

Learn more about nbmake at https://github.com/treebeardtech/nbmake

================================================================================================================================================================================= short test summary info ================================================================================================================================================================================== 
FAILED docs/projects/illusion.ipynb::

Environment

alex-treebeard commented 7 months ago

Hi @rcpeene - thanks for taking the time to report this and apologies for being slow to respond.

Windows is awkward. I've found that the libraries we depend on in the jupyter stack (e.g. nbclient, jupyter-server) are less reliable and less tested on Windows.

As such we don't test on windows (IIRC), yet many people still use nbmake on it.

I'm unable to look into this right now but I'd suggest dropping this issue into our discord and seeing if other users can support: https://discord.com/invite/QFjCpMjqRY

rcpeene commented 7 months ago

I had had other environment problems with other Python projects at the same time; Not a real fix to the problem but a total reinstallation of Python fixed the issue. I suspect it has to do with windows looking at two different installations of Python

alex-treebeard commented 6 months ago

yes the interaction between jupyter and python binaries on the file system can be brittle, especially with multiple installations/virtual environments.

Glad that's fixed!