调试器警告来自ipython: Frozen Modules [python 3.11]



我使用conda创建了一个新环境,并希望将其添加到jupyter-lab中。我收到模块冻结的警告了吗?(如下所示)

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

所有我安装的是…

ipykernel, ipython, ipywidgets, jupyterlab_widgets, ipympl

Python版本3.11.0,Conda版本22.11.0

我使用"conda install nodejs -c conda-forge——repodata-fn=repodata.json"获取最新版本的nodejs

我还尝试将ipykernel重新安装到以前的版本(6.20.1 ->6.19.2)

这只是一个警告,调试器不能调试冻结的模块。

">在Python 3.11中,Python启动所必需的核心模块被"冻结". ...这减少了模块执行过程中的步骤…在Python 3.11中,解释器启动速度现在快了10-15%。这对使用Python的短时间运行程序有很大的影响。">
- https://docs.python.org/3/whatsnew/3.11.html#faster-startup

">调试器不可能调试冻结的模块,因为文件名必须命中断点">
- https://github.com/fabioz/PyDev.Debugger/issues/213#issuecomment-1058247166

os.path.realpath.__code__.co_filename在Python 3.11中现在是'<frozen posixpath>'


警告中提到了可能的分辨率。

  1. 如果需要调试这些模块,将-Xfrozen_modules=off传递给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. 如果您只想抑制警告,则设置PYDEVD_DISABLE_FILE_VALIDATION=1:
PYDEVD_DISABLE_FILE_VALIDATION=1 ipython kernel install --user --name=testi2
PYDEVD_DISABLE_FILE_VALIDATION=1 jupyter-lab

我注意到的主要问题是,当你试图在visual studio上运行python而没有py扩展时,你很可能会遇到这样的问题最后确保python路径被添加到环境变量中。我已经这样做了,它的工作很好。我正在使用Visual studio。在Windows上总是可以在这里找到路径C:UsersNEWAppDataLocalProgramsPython Python311

最新更新