Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugger warning from IPython: frozen modules

I created a new environment using conda and wanted to add it to jupyter-lab. I got a warning about frozen modules? (shown below)

$ ipython kernel install --user --name=testi2 
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Installed kernelspec testi2 in /home/michael/.local/share/jupyter/kernels/testi2

All I had installed were ipykernel, ipython, ipywidgets, jupyterlab_widgets, ipympl

Python Version 3.11.0, Conda version 22.11.0

And I used conda install nodejs -c conda-forge --repodata-fn=repodata.json to get the latest version of nodejs

I also tried re-installing ipykernel to a previous version (6.20.1 -> 6.19.2)

like image 517
Elijah Avatar asked Sep 07 '25 05:09

Elijah


1 Answers

This is just a warning that the debugger cannot debug frozen modules.

In Python 3.11, the core modules essential for Python startup are “frozen”. ... This reduces the steps in module execution process ... Interpreter startup is now 10-15% faster in Python 3.11. This has a big impact for short-running programs using Python.

— What’s New In Python 3.11 § Faster Startup

it's not possible for the debugger to debug frozen modules as the filename is definitely required to hit breakpoints

— https://github.com/fabioz/PyDev.Debugger/issues/213#issuecomment-1058247166

E.g. os.path.realpath.__code__.co_filename is now '<frozen posixpath>' in Python 3.11.


The possible resolutions are mentioned with the warning.

  1. If you need to debug those modules, pass -Xfrozen_modules=off to python:

    # ipython kernel install --user --name=testi2
    python -Xfrozen_modules=off -m ipykernel install --user --name=testi2
    
    # jupyter-lab
    python -Xfrozen_modules=off -m jupyterlab
    
  2. If you just want to suppress the warning, set PYDEVD_DISABLE_FILE_VALIDATION=1:

    PYDEVD_DISABLE_FILE_VALIDATION=1 ipython kernel install --user --name=testi2
    
    PYDEVD_DISABLE_FILE_VALIDATION=1 jupyter-lab
    
like image 187
aaron Avatar answered Sep 08 '25 20:09

aaron