所以我刚刚安装了 python 版本 3.11 并更改了 pycharm 中的 python 解释器,并且在将软件包重新安装到新的 venv 后,代码现在可以正常运行了。
但是当我调试代码时,我不断收到一长串警告,但我不知道如何修复它:
-------------------------------------------------------------------------------
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>
我为所有用户将其安装到 C:\Program Files 如果有帮助的话
应在 PyCharm 2022.3 中修复(票证 https://youtrack.jetbrains.com/issue/PY-56939/CRITICAL-WARNING-error-debugging-Python-311-code)。
抢先体验预览版已经推出 https://www.jetbrains.com/pycharm/nextversion/
对我来说,这个错误只是因为错误地调用了函数而出现的。我有相互引用的参数。
funct(my_array, my_array[0])
降级 Python 也是一种选择。这对于创建新的 Anaconda 环境进行测试特别简单快捷。
在 3.12 下有此错误,但在 3.10 PyCharm 解释器下没有。
如果您碰巧在 fastApi 中遇到此错误,您可以禁用重新加载来启动它,断点将再次起作用
uvicorn.run("bootstrap:app", host="0.0.0.0", port=8080, reload=False)
更新 pycharm 或将 python 降级到 3.10 也可以