mdickinson@mirzakhani Desktop % python -m venv --clear testing && source testing/bin/activate
(testing) mdickinson@mirzakhani Desktop % pip install 'ipykernel<6'
Collecting ipykernel<6
Using cached ipykernel-5.5.5-py3-none-any.whl (120 kB)
Collecting appnope
Using cached appnope-0.1.2-py2.py3-none-any.whl (4.3 kB)
Collecting jupyter-client
Using cached jupyter_client-7.0.2-py3-none-any.whl (122 kB)
Collecting ipython>=5.0.0
Using cached ipython-7.27.0-py3-none-any.whl (787 kB)
Collecting tornado>=4.2
Using cached tornado-6.1-cp39-cp39-macosx_10_9_x86_64.whl (416 kB)
Collecting traitlets>=4.1.0
Using cached traitlets-5.1.0-py3-none-any.whl (101 kB)
Collecting backcall
Using cached backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: setuptools>=18.5 in ./testing/lib/python3.9/site-packages (from ipython>=5.0.0->ipykernel<6) (57.4.0)
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
Using cached prompt_toolkit-3.0.20-py3-none-any.whl (370 kB)
Collecting pygments
Using cached Pygments-2.10.0-py3-none-any.whl (1.0 MB)
Collecting matplotlib-inline
Using cached matplotlib_inline-0.1.2-py3-none-any.whl (8.2 kB)
Collecting pexpect>4.3
Using cached pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
Collecting jedi>=0.16
Using cached jedi-0.18.0-py2.py3-none-any.whl (1.4 MB)
Collecting decorator
Using cached decorator-5.0.9-py3-none-any.whl (8.9 kB)
Collecting pickleshare
Using cached pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting parso<0.9.0,>=0.8.0
Using cached parso-0.8.2-py2.py3-none-any.whl (94 kB)
Collecting ptyprocess>=0.5
Using cached ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting wcwidth
Using cached wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Collecting python-dateutil>=2.1
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting entrypoints
Using cached entrypoints-0.3-py2.py3-none-any.whl (11 kB)
Collecting jupyter-core>=4.6.0
Using cached jupyter_core-4.7.1-py3-none-any.whl (82 kB)
Collecting pyzmq>=13
Using cached pyzmq-22.2.1-cp39-cp39-macosx_10_15_universal2.whl (2.0 MB)
Collecting nest-asyncio>=1.5
Using cached nest_asyncio-1.5.1-py3-none-any.whl (5.0 kB)
Collecting six>=1.5
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: wcwidth, traitlets, six, ptyprocess, parso, tornado, pyzmq, python-dateutil, pygments, prompt-toolkit, pickleshare, pexpect, nest-asyncio, matplotlib-inline, jupyter-core, jedi, entrypoints, decorator, backcall, appnope, jupyter-client, ipython, ipykernel
Successfully installed appnope-0.1.2 backcall-0.2.0 decorator-5.0.9 entrypoints-0.3 ipykernel-5.5.5 ipython-7.27.0 jedi-0.18.0 jupyter-client-7.0.2 jupyter-core-4.7.1 matplotlib-inline-0.1.2 nest-asyncio-1.5.1 parso-0.8.2 pexpect-4.8.0 pickleshare-0.7.5 prompt-toolkit-3.0.20 ptyprocess-0.7.0 pygments-2.10.0 python-dateutil-2.8.2 pyzmq-22.2.1 six-1.16.0 tornado-6.1 traitlets-5.1.0 wcwidth-0.2.5
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/mdickinson/Desktop/testing/bin/python -m pip install --upgrade pip' command.
(testing) mdickinson@mirzakhani Desktop % python
Python 3.9.7 (default, Sep 1 2021, 04:00:27)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipykernel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mdickinson/Desktop/testing/lib/python3.9/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/mdickinson/Desktop/testing/lib/python3.9/site-packages/ipykernel/connect.py", line 13, in <module>
from ipython_genutils.path import filefind
ModuleNotFoundError: No module named 'ipython_genutils'
>>>
With the release of Traitlets 5.1, it appears that an
ipykernelinstalled withpip install 'ipykernel < 6'isn't immediately usable:ipython_genutilsis not installed into the environment, and animport ipykernelgives aModuleNotFoundError: No module named 'ipython_genutils'. It looks as thoughipykerneldepends onipython_genutilsand is currently relying on the traitlets dependencies to ensure thatipython_genutilsis installed, but since Traitlets 5.1,ipython_genutilsis no longer a dependency oftraitlets. Moreover, explicitly installingipython_genutilsseems like the wrong solution, since the PyPI page seems to instruct us that we shouldn't need to know aboutipython_genutils. :-)It's not clear to me whether this should be classified as a traitlets issue, an ipykernel issue, or a non-issue; it was the Traitlets release that triggered the issue, but presumably if it's deemed worth fixing, then fixing in the 5.x maintenance branch here (e.g., by adding
ipython_genutilsas an explicit dependency) makes most sense. Apologies if I've opened this in the wrong place.Steps to reproduce in a clean Python 3.9 venv:
pip install 'ipykernel < 6'import ipykernel. The expectation is that this would succeed, but it fails with aModuleNotFoundError.Here are the results on my (macOS 10.15.7) machine.
Details
For context: we have some code that works closely with ipykernel. That code currently works with ipykernel 5, but it will take some effort to make it compatible with ipykernel 6. In the meantime, we put an
ipykernel < 6version restriction in place, and then ran into this issue. This isn't an issue for us: we already have a workaround in place (addingtraitlets < 5.1to our dependencies), but it seemed worth reporting in case it affects others.