New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pandas/NumPy code exhibits unusual behavior, but only running with debugpy. #801
Comments
I'm receiving the same error (with similar conclusions after debugging) in Pycharm when running a |
What is the pandas version? Does this happen when you just do a run in the debugger (without hitting any breakpoints) or only when stepping? As a note, while this happens under the debugger, it does seem much more a case of something wrong in pandas and not in the debugger (the debugger does exercise different paths and that may be triggering the bug) -- the fact that this is MacOS only makes that even more likely (I tried it on Windows and I couldn't reproduce it, although I may have a diferent pandas version). |
One thing to check is trying to run with the environment variables below (that way at least the debugger won't try to load any compiled extensions):
and see if it makes any difference (p.s.: still waiting for more info...) |
Same bug here in PyCharm 2021.3.1 with Python 3.10 (venv). I tried the environment settings but still same bug. |
@maddin79, are you also on an M1 machine? And you, @AlesiRowland ? If this is happening in PyCharm its not strictly a debugpy issue but we can leave it here seeing as it is an issue for @fabioz . It would be useful I think in each case to know how you installed Python, and whether your Python is an x64 binary running under Rosetta emulation, or a native ARM64 binary. |
It's very likely related to numpy/numpy#21008 and doesn't depend on the underlying machine architecture |
@gramster No, I'm on Linux. Manjaro XFCE |
@fabioz Just seeing your responses now. I am still having this issue, now on Python 3.10.2 (via PyEnv). Just upgraded pandas, now using Pandas v1.4.1 and NumPy 1.22.2. This happens when I run in the debugger with no break points. Furthermore, if I copy the triggering line of code into the debug console I get the same issue/error. I can't quite figure out how to tell if I'm using an Intel binary in Rosetta2 vs ARM, but I'm inclined to say ARM? I installed using PyEnv. This causes this error: I set the env variables as you suggested above with no change. I am also having the issue documented in microsoft/debugpy#835. |
Same issue in PyCharm. Windows 10 x64. Python 3.10.3 |
As a note, this doesn't seem to be fixable in debugpy. The actual culprit (from the comment at: numpy/numpy#21008 (comment)) seems to be an issue with cython. I think we can leave the issue open here for now (so that people can see this is a real issue), even though the fix is not doable in the debugger side (note that numpy/numpy#21008 does list compiling numpy with a |
Thanks for pointing out this possible work around. I hadn't seen that suggestion. Will try when I have some time to screw around with it. |
Another workaround there is:
So, presumably they have that fixed already, just not in a stable version... |
Closing as there's not much we can do about it... For anyone arriving here, see posts above with workarounds: |
I am using Macbook Pro with M1 and am having the same error with the following code:
My IDE is PyCharm 2021.3.2 with pandas 1.4.2, numpy 1.22.3 and cython 0.29.30. |
@merjekrepo It seems there's numpy |
Yes @fabioz, it worked after installing those packages. You saved me from switching back to Windows :) Thanks a lot! |
Environment data
import debugpy; print(debugpy.__version__)
if uncertain)Actual behavior
Running the following script produces the error below:
The error:
More detailed error trace below.
Expected behavior
Running the script outside of the debger runs without error.
The exception seems to be coming from here:
File "~/.pyenv/versions/3.10.0/envs/_/lib/python3.10/site-packages/numpy/lib/function_base.py", line 2223, in <listcomp> otypes = "".join([_nx.dtype(x).char for x in otypes])
numpy.core.numerics
(assigned to_nx
) seems to be the problem here. Inside the debuger,_nx.dtype
is None, but outside the debugger it has a value of<class 'numpy.dtype'>
.There is no issue running this in the debuger when using homebrewed python instead. The key numpy files appear to be the same though, as far as I can tell.
Steps to reproduce:
Issue Type: Bug
Machine: MacBook Air 2020 (M1)
Environment: Python 3.10.0, installed via PyEnv
Summary:
When running the VS Code debuger, the following code has an error. The code runs fine when running the code without the VS Code debuger, either via the "Run Python File" button in VS Code or simply on the commandline, but using the same python environment/executable.
I am only having this problem on my M1 MacBook Air. Runs fine on an older MacBook Pro, and in WSL. Furthermore, this issue seemingly has only arrisen in this past week, since I went through some riggamarol to solve an issue where lzma wasn't getting installed. I tried a bunch of things there and eventually one of them worked after seeming repetiton, so it's difficult to unwind this unfortunately.
Debug Config:
Python code:
The error:
Diving in, this actually seems to be an error in NumPy, specifically in numpy.core.numerics.py.
Here is a more in depth trace:
When I dig in and but a break point at
~/.pyenv/versions/3.10.0/envs/_/lib/python3.10/site-packages/numpy/lib/function_base.py
, line 2223 and check _nx.dtype, it is None. However, higher up in the file it returns <class 'numpy.dtype'>.I'm stumped, help!
VS Code version: Code 1.62.3 (Universal) (ccbaa2d27e38e5afa3e5c21c1c7bef4657064247, 2021-11-17T07:59:13.865Z)
OS version: Darwin arm64 21.1.0
Restricted Mode: No
System Info
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (24)
(1 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: