Spyder 调试器在 Anaconda 虚拟环境中冻结

发布于 2025-01-08 23:49:09 字数 1486 浏览 1 评论 0原文

我正在使用 Anaconda 虚拟环境 venv,并从中运行 Spyder。

每当我尝试调试代码时,什么也没有发生。调试器似乎卡在第一行。例如,如果我运行调试器:

import sys

print(sys.executable)

在调试模式下运行会在内置 IPython 控制台上生成以下输出:

debugfile('C:/Projects/Myproject/myscript.py', wdir='C:/Projects/Myproject')
> c:\projects\myproject\myscript.py(1)<module>()
----> 1 import sys
      2 
      3 print(sys.executable)

Spyder 中的“调试”按钮及其相关快捷方式似乎都不起作用。特别是,按“停止”按钮(或按 CTRL+SHIFT+F12)会导致:

--KeyboardInterrupt--
For copying text while debugging, use Ctrl+Shift+C

我已经做了一些研究,并找到了这个 GitHub 问题页面,建议我更新 IPython。我做了,没有任何好处。

我在此发现的另一个建议 其他 GitHub 页面 表明问题可能是运行了错误的 Python 可执行文件(即,Spyder 是从我的基本 Anaconda 环境运行 Python,而不是我的venv)。我检查过,两者都是从正确的路径运行的:

print(sys.executable)

C:\Anaconda3\envs\venv\python.exe

这些是​​我的依赖项的版本。

Spyder version: 5.1.5 None
Python version: 3.7.11 64-bit
Qt version: 5.9.7
PyQt5 version: 5.9.2
IPython 7.31.1
Operating System: Windows 10

I'm working with an Anaconda virtual environment, venv, and I'm running Spyder from it.

Whenever I attempt debugging my code, nothing happens. The debugger seems to get stuck in the first line. For example, if I run the debugger on:

import sys

print(sys.executable)

Running in debug mode produces this output on the built-in IPython console:

debugfile('C:/Projects/Myproject/myscript.py', wdir='C:/Projects/Myproject')
> c:\projects\myproject\myscript.py(1)<module>()
----> 1 import sys
      2 
      3 print(sys.executable)

Neither Debugging buttons in Spyder, nor their related shortcuts, seem to do anything. In particular, pressing the Stop button (or hitting CTRL+SHIFT+F12) results in:

--KeyboardInterrupt--
For copying text while debugging, use Ctrl+Shift+C

I have already made some research, and landed on this GitHub issue page, where it is suggested that I should update IPython. I did, with no benefit.

Another suggestion I found in this other GitHub page indicated the problem might be that the wrong executable for Python is run (i.e., that Spyder is running Python from my base Anaconda environment, rather than my venv). I checked, and both are run from the right path:

print(sys.executable)

C:\Anaconda3\envs\venv\python.exe

These are the version of my dependencies.

Spyder version: 5.1.5 None
Python version: 3.7.11 64-bit
Qt version: 5.9.7
PyQt5 version: 5.9.2
IPython 7.31.1
Operating System: Windows 10

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满天都是小星星 2025-01-15 23:49:09

我面临同样的问题,Spyder 5.1.5 调试在新环境中不起作用。据我了解,版本之间存在一些冲突,但承诺他们将在下一个版本中处理该问题。

另外,这是一个报告的问题: https://github.com/spyder-ide/ pyder/issues/17350

对我来说似乎有用的是创建一个新环境,但指定如下版本:

conda create -n your_fancy_env_name -c conda-forge python=3.8.10 spyder=5.1.5

I face the same issue, Spyder 5.1.5 debugging does not work in new environments. There is some clash between versions as I understand, but promised that they will deal with the issue in the next version.

Also, this is a reported issues: https://github.com/spyder-ide/spyder/issues/17350

What seems to work for me is to create a new environment but specify the versions like this:

conda create -n your_fancy_env_name -c conda-forge python=3.8.10 spyder=5.1.5
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文