23

I've been searching for some time but couldn't find any related problem.

When using Visual Studio Code with Python extension for debugging on large elements, computing a representation or getting an attribute may take some time.

In these cases a warning like:

pydevd warning: Computing repr of ... (DataFrame) was slow (took 0.84s)

is printed to the debug console (also see https://www.pydev.org/history_pydev.html).

Even more annoying, a popup turns up on the lower left corner.

Is there any way to disable these warnings and in particular this popup concerning this warning?

I have tried more or less everything what I found with respect to logging and warning in Visual Studio Code debugging.

A minimal example would look like

import pandas as pd

df = pd.read_csv('file of 1GB')

df

The warning is not a warning on a particular line but a warning given by the debugger everytime the large object is used (e.g. just printed or with an operation df.some_operation()).

  1. Screenshot of warning at breakpoint
  2. Screenshot of warning everytime the object is printed in the debug console
feetwet
  • 3,248
  • 7
  • 46
  • 84
mknaranja
  • 341
  • 1
  • 2
  • 6
  • Die you already tried something like: https://stackoverflow.com/questions/7254015/suppress-warnings-in-pydev#:~:text=In%20PyDev%2C%20whenever%20there's%20an,%2Fwarning%20will%20be%20ignored). – Tom Hammerbacher Mar 31 '22 at 16:07
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 31 '22 at 16:30
  • @TomHammerbacher The problem is different as this is not a warning with respect to one particular line but a warning that is given with the execution of the debugger anytime an operation is done on a large object. – mknaranja Mar 31 '22 at 17:01

4 Answers4

29

As Fabio Zadrozny suggested, you can change the environment variable, PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT, to the preferred time.

I fixed it by adding the following line to the "launch.json" file in Visual Studio Code.

"env": {"PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT": "2"}

So my "launch.json" looks something like this:

...
"launch": {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "env": {"PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT": "2"}
        }
    ]
}
...
JBSnorro
  • 6,048
  • 3
  • 41
  • 62
Lasse Madsen
  • 391
  • 2
  • 3
  • 1
    That is great. Thanks a lot, this solves my problem. May I ask where you find these things documented? I have gone through the whole VSCode debugging, python extensions settings & documentation as well as searched on the PyDev website but found nothing... – mknaranja Apr 05 '22 at 08:23
  • I've added it to launch.json. Maybe my VScode is configured differently from yours – Alon Samuel Jun 28 '22 at 10:37
  • This one makes the warning appear as pop-up, instead of warning in terminal. Which is good enough to solve my issue. Thanks. – Mosen Aug 08 '22 at 08:18
  • 1
    I'm debugging the jupyter cell in VSCode, I don't know why not work. – huang Sep 09 '22 at 09:45
6

What you can do here is set an environment variable to change the timeout before it's reported.

Note that the default is 0.15s (a small number is used because there are cases where thousands of such small delays during the repr are given and the debugger can appear to be stuck when it's actually because user-code is too slow to compute its repr).

You can change it setting an environment variable such as:

PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT=2

(this will change the timeout to 2 seconds).

Note that the real fix here would be pandas improving its repr implementation so that it'd be faster...

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • 1
    That is great. Thanks a lot, this solves my problem. May I ask where you find these things documented? I have gone through the whole VSCode debugging, python extensions settings & documentation as well as searched on the PyDev website but found nothing... – mknaranja Apr 05 '22 at 08:24
  • Unfortunately I think this isn't really documented anywhere -- right now this answer is probably the best documentation around it ;) – Fabio Zadrozny Apr 06 '22 at 10:29
  • how do you know about it then? and how do you set this environment variable? – DarQ Apr 07 '22 at 00:14
  • @DarQ See Lasse Madsen's answer below. This is very helpful. – mknaranja Apr 07 '22 at 09:06
  • I did see his answer but unfortunately it didn't work. I also tried modifying launch.json to no avail. note that my warning is a bit different: `pydevd warning: Computing repr of soup (BeautifulSoup) was slow (took 1.00s)` note sure if that's relevant. – DarQ Apr 09 '22 at 13:04
  • Is there a way to set this for all configurations? I have ~50 debug launch configurations and it'd be a pain to do it for all of them... thanks! – Isaac Wolf Apr 14 '22 at 22:24
  • Yes, you can set the environment variables in your OS (which should then be inherited when you start VSCode again). – Fabio Zadrozny Apr 16 '22 at 10:44
1

Had the issue. On my Ubuntu environment, I just declared the variable:

$ export PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT=10

Then ran VSCODE and verified in the terminal that the variable is set:

$ echo $PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT
10

And that's it.

1

Just adding this to the launch.json worked for me.

"env": {
            "PYDEVD_DISABLE_FILE_VALIDATION": "1"
        }

If you are using Django debugger, your launch.json should look like:

{

"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Django",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/manage.py",
        "args": [
            "runserver",
        ],
        "django": true,
        "env": {
            "PYDEVD_DISABLE_FILE_VALIDATION": "1"
        }
    },
    
]

}

Dinesh Roy
  • 141
  • 4
  • 12