Home > Net >  Spyder debugger freezes within Anaconda virtual environment
Spyder debugger freezes within Anaconda virtual environment

Time:02-26

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

CodePudding user response:

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
  • Related