Python 3.11在PyCharm中调试异常:大量警告无法解决
Python 3.11 + PyCharm调试时PyDev警告的解决方法
问题现象
代码可正常运行,但调试时弹出大量PyDev警告:
------------------------------------------------------------------------------- pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute) pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints. pydev debugger: Related bug: http://bugs.python.org/issue1666807 ------------------------------------------------------------------------------- Connected to pydev debugger (build 221.5080.212) pydev debugger: Unable to find real location for: <frozen codecs> pydev debugger: Unable to find real location for: <frozen importlib._bootstrap> pydev debugger: Unable to find real location for: <frozen importlib._bootstrap_external> pydev debugger: Unable to find real location for: <frozen zipimport> pydev debugger: Unable to find real location for: <frozen ntpath> pydev debugger: Unable to find real location for: <frozen genericpath> pydev debugger: Unable to find real location for: <frozen os> pydev debugger: Unable to find real location for: <frozen _collections_abc> pydev debugger: Unable to find real location for: <string> pydev debugger: Unable to find real location for: <frozen abc> pydev debugger: Unable to find real location for: <__array_function__ internals> pydev debugger: Unable to find real location for: <frozen io>
注:Python安装在C:\Program Files(全局路径)。
解决方法
方法一:重装Python到无空格路径(推荐)
- 卸载当前Python 3.11,重新安装到无空格的路径,比如
C:\Python311 - 安装时勾选「Add Python to PATH」,选择「仅为当前用户安装」(避免权限及路径解析问题)
- 删除项目旧的venv文件夹,在PyCharm中重新创建虚拟环境,选择新安装的Python 3.11作为基础解释器
方法二:禁用PyDev文件路径校验(无需重装)
- 打开PyCharm的「Run/Debug Configurations」(右上角运行按钮下拉框→Edit Configurations)
- 选中你的调试配置,切换到「Configuration」标签页
- 点击「Environment variables」,添加变量
PYDEVD_DISABLE_FILE_VALIDATION=1 - 保存配置后重启PyCharm,重新调试
验证
调试项目,查看警告是否消失,调试功能是否正常使用。
内容的提问来源于stack exchange,提问作者maxxel_
相关产品推荐
相关产品推荐

