13

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)

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Elijah
  • 133
  • 1
  • 7

2 Answers2

15

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."
https://docs.python.org/3/whatsnew/3.11.html#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
  1. 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
aaron
  • 39,695
  • 6
  • 46
  • 102
  • why would there need to be any debugging of modules when adding a conda virtual environment to jupyter lab? – tumultous_rooster Jan 29 '23 at 11:26
  • There is no need to. The validation is run at import time: ipkernel.py `from .debugger import ...` → `from debugpy.server import ...` → `import debugpy._vendored.force_pydevd` → `preimport('pydevd', [..., 'pydevd',])` → `import pydevd_file_utils` → filename validation. – aaron Jan 29 '23 at 12:12
  • Related to this: a follow-up question [here](https://stackoverflow.com/q/76149677/8508004) about where to put `PYDEVD_DISABLE_FILE_VALIDATION=1 jupyter-lab`. I'm just tagging this with a temporary comment in the hopes those knowledgeable may see the new post. New poster cannot comment yet. – Wayne May 03 '23 at 02:21
0

The main problem i noticed with this is that when you try to run python on visual studio without without a py extension you're most likely to run into an issue like this and Finally make sure python path is added to Environment Variable . I have done this and its working fine . I am Using Visual studio. Path is always found here on Windows C:\Users\NEW\AppData\Local\Programs\Python\Python311

code11
  • 11