pynapple-org / pynapple

PYthon Neural Analysis Package :pineapple:
https://pynapple-org.github.io/pynapple/
MIT License
257 stars 61 forks source link

Fatal exception using pynapple in IPython console #318

Open cameron-woodard opened 1 month ago

cameron-woodard commented 1 month ago

Hi, I'm running scripts that use pynapple through an IPython console in the Spyder IDE and I keep running into the following error:

Windows fatal exception: access violation

Thread 0x00005968 (most recent call first): File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\zmq\utils\garbage.py", line 47 in run File "C:\Users\Cam\miniconda3\envs\pynapple\lib\threading.py", line 932 in _bootstrap_inner File "C:\Users\Cam\miniconda3\envs\pynapple\lib\threading.py", line 890 in _bootstrap

Main thread: Current thread 0x000037a0 (most recent call first): File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\pynapple\core_core_functions.py", line 33 in _count File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\pynapple\core\ts_group.py", line 704 in count File "c:\users\cam\documents\python scripts\ephys analysis\be05_behavior_spiking_analysis.py", line 1845 in File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\spyder_kernels\py3compat.py", line 356 in compat_exec File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 473 in exec_code File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 740 in _exec_cell File "C:\Users\Cam\miniconda3\envs\pynapple\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 689 in runcell File "C:\Users\Cam\AppData\Local\Temp\ipykernel_20848\4094378172.py", line 1 in

This results in the kernel crashing and restarting. The first section with the garbage collection thread is not always present, so I don't think that has anything to do with it. It looks to me like the issue happens when the count function is called? It doesn't happen every time I use count, but invariably occurs when I'm running loops that involve shuffling unit activity and running count hundreds of times. I tried deleting the pynapple environment and making it again from scratch but it didn't help. I'm using the latest version of pynapple. Any ideas?

gviejo commented 1 month ago

Hi Ok it's a weird error. Does it happen if you call it outside spyder?

The function count is compiled with numba under the hood. It might be an issue with numba here but not sure. If you are comfortable with it, you can try to disable the compiling of the count function with the following steps:

git clone git@github.com:pynapple-org/pynapple.git cd pynapple Make sure you are in the right conda environment pip install -e . Open ~/pynapple/pynapple/core/_jitted_functions.py amd comment line 120. Call again your scripts

If it works, there might be an incompatibility with numba with something else. If it doesn't work, you can paste the error here.