Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with IPython >= 9.0.0 #288

Open
ELC opened this issue Mar 2, 2025 · 0 comments
Open

Incompatibility with IPython >= 9.0.0 #288

ELC opened this issue Mar 2, 2025 · 0 comments

Comments

@ELC
Copy link

ELC commented Mar 2, 2025

Metakernel has a "hidden" dependency on IPython, hidden because it is not explicitly stated in the pyproject.toml:

dependencies = [
"ipykernel >=5.5.6,<7",
"jupyter_core >=4.9.2",
"pexpect >=4.8",
"jedi >=0.18",
]

However, there are parts of the code that explicitly import from IPython:

try:
from IPython.utils.PyColorize import NeutralColors
RED = NeutralColors.colors["header"]
NORMAL = NeutralColors.colors["normal"]
except:
from IPython.core.excolors import TermColors
RED = TermColors.Red
NORMAL = TermColors.Normal

This is relevant in this case because in the latest release of IPython, v9.0.0, there was a massive refactor on how colors are managed:
ipython/ipython@a796b95

This changes are backwards incompatible and make kernels derived from metakernel failed. I encounter this in the octave-kernel:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/octave_kernel/__init__.py", line 4, in <module>
    from .kernel import OctaveKernel
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/octave_kernel/kernel.py", line 19, in <module>
    from metakernel import MetaKernel, ProcessMetaKernel, REPLWrapper, u, MetaKernelApp
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/metakernel/__init__.py", line 2, in <module>
    from ._metakernel import (
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/metakernel/_metakernel.py", line 40, in <module>
    from IPython.core.excolors import TermColors
ModuleNotFoundError: No module named 'IPython.core.excolors'
[I 2025-03-02 16:28:56.633 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports
Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/metakernel/_metakernel.py", line 36, in <module>
    from IPython.utils.PyColorize import NeutralColors
ImportError: cannot import name 'NeutralColors' from 'IPython.utils.PyColorize' (/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/IPython/utils/PyColorize.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/octave_kernel/__init__.py", line 4, in <module>
    from .kernel import OctaveKernel
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/octave_kernel/kernel.py", line 19, in <module>
    from metakernel import MetaKernel, ProcessMetaKernel, REPLWrapper, u, MetaKernelApp
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/metakernel/__init__.py", line 2, in <module>
    from ._metakernel import (
  File "/home/ubuntu/.pyenv/versions/3.11.9/lib/python3.11/site-packages/metakernel/_metakernel.py", line 40, in <module>
    from IPython.core.excolors import TermColors
ModuleNotFoundError: No module named 'IPython.core.excolors'

There is a need for a patch in metakernel where the version is set strictly to IPython < 9.0.0 and a future fix where the code is refactored so that it is compatible with IPython ~= 9.0.0

guitargeek added a commit to guitargeek/root that referenced this issue Mar 3, 2025
The newest `ipython` broke the `newest` metakernel package.

See also the upstream report:
Calysto/metakernel#288

Restricting the ipython version, at least until the problem is fixed
upstream in the ipython/metakernel duo, will solve the problem for all
ROOT branches, because the `requirements.txt` is used for all CI images.

I was a bit hesitant if this is really the solution because the problem
seems to be platform-dependent. However, that seems to be because
ipython 9.0.0 has not reached all of pips channels yet. Compare for
example these build logs:

Ubuntu 24.04, picks up `ipython==8.33.0`
https://productionresultssa15.blob.core.windows.net/actions-results/7a5c1f23-ff80-468b-80dd-33e4511651f6/workflow-job-run-5f5bc846-a2a7-5fbf-b892-8ca7512cbcea/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-03-03T09%3A12%3A05Z&sig=3lsuZ7wxDHR804tfJJdV0hj8o2pktHyD1cNe92gvKSI%3D&ske=2025-03-03T20%3A43%3A42Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-03-03T08%3A43%3A42Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-03-03T09%3A02%3A00Z&sv=2025-01-05

Fedora 41 picks up `ipython==9.0.0`:
https://productionresultssa15.blob.core.windows.net/actions-results/7a5c1f23-ff80-468b-80dd-33e4511651f6/workflow-job-run-c55417ba-26e1-5c15-ea21-28e4787be48e/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-03-03T09%3A11%3A25Z&sig=5Q8wyCvctlAA18IQ23rJj3TAe2Sv%2FHNRrWK%2B8JZ84cI%3D&ske=2025-03-03T20%3A36%3A35Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-03-03T08%3A36%3A35Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-03-03T09%3A01%3A20Z&sv=2025-01-05
guitargeek added a commit to root-project/root that referenced this issue Mar 3, 2025
The newest `ipython` broke the `newest` metakernel package.

See also the upstream report:
Calysto/metakernel#288

Restricting the ipython version, at least until the problem is fixed
upstream in the ipython/metakernel duo, will solve the problem for all
ROOT branches, because the `requirements.txt` is used for all CI images.

I was a bit hesitant if this is really the solution because the problem
seems to be platform-dependent. However, that seems to be because
ipython 9.0.0 has not reached all of pips channels yet. Compare for
example these build logs:

Ubuntu 24.04, picks up `ipython==8.33.0`
https://productionresultssa15.blob.core.windows.net/actions-results/7a5c1f23-ff80-468b-80dd-33e4511651f6/workflow-job-run-5f5bc846-a2a7-5fbf-b892-8ca7512cbcea/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-03-03T09%3A12%3A05Z&sig=3lsuZ7wxDHR804tfJJdV0hj8o2pktHyD1cNe92gvKSI%3D&ske=2025-03-03T20%3A43%3A42Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-03-03T08%3A43%3A42Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-03-03T09%3A02%3A00Z&sv=2025-01-05

Fedora 41 picks up `ipython==9.0.0`:
https://productionresultssa15.blob.core.windows.net/actions-results/7a5c1f23-ff80-468b-80dd-33e4511651f6/workflow-job-run-c55417ba-26e1-5c15-ea21-28e4787be48e/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-03-03T09%3A11%3A25Z&sig=5Q8wyCvctlAA18IQ23rJj3TAe2Sv%2FHNRrWK%2B8JZ84cI%3D&ske=2025-03-03T20%3A36%3A35Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-03-03T08%3A36%3A35Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-03-03T09%3A01%3A20Z&sv=2025-01-05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant