Closed ba05 closed 7 months ago
Hey @ba05, thanks for reporting. Could you confirm that running that code outside Spyder works as expected?
Yes I can confirm. Works fine running from a Python CLI inside an environment without Spyder installed.
(Copying original comment from IPython to have it here for quick reference)
To reproduce issue:
mamba create --name testEnv python=3.12 spyder scipy numpy
At the python console:
import numpy as np
import scipy.signal as signal
np.cov([1,2,3],[1.1, 2.1, 3]) # works, no error
signal.savgol_filter([1,2,3], window_length=2, polyorder=1) # works, no error
The above results in "Windows fatal exception: code 0xc06d007e" when run on the Spyder ipython console.
Packages:
Originally posted by @ba05 in https://github.com/ipython/ipython/issues/14266#issuecomment-1915179626
Yes I can confirm. Works fine running from a Python CLI inside an environment without Spyder installed.
So, the problem persists if you install Spyder in the environment and run that code outside of it?
The problem never appears in the Python CLI with Spyder installed in the environment.
I did some more testing on my end. Running the following code...:
import numpy as np
import scipy.signal as signal
np.cov([1,2,3],[1.1, 2.1, 3])
signal.savgol_filter([1,2,3], window_length=2, polyorder=1)
with the following configs:
1) works: Running from CLI with Spyder installed environment. 2) works: Running from Spyder IPython (launching Spyder by typing 'spyder' at mamba command prompt). 3) fails: Running from Spyder IPython (launching Spyder from Windows Start menu shortcut).
The environments above were created using mamba. Now, if I create a mamba environment with Spyder and then:
pip uninstall numpy scipy
pip install numpy scipy
3) works: Running from Spyder IPython (launching Spyder from Windows Start menu shortcut).
Error seen when failure occurs:
Windows fatal exception: code 0xc06d007e
Main thread:
Current thread 0x00007bcc (most recent call first):
File "C:\Users\AronBW\AppData\Local\miniforge3\envs\testEnv3\Lib\site-packages\numpy\lib\function_base.py", line 2747 in cov
File "C:\Users\AronBW\AppData\Local\Temp\ipykernel_29652\2177909138.py", line 1 in <module>```
Restarting kernel...
Why does the pip uninstall / install fix things? And why is there no error when Spyder is launched from the mamba prompt versus the Windows start menu shortcut?
I am seeing the same issue with scipy.optimize.curve_fit. I found that I could run the code as a Jupyter notebook in the same environment without problem, but after converting it to a script the code crashed the kernel in Spyder. I was also able to run the script using WSL (Ubuntu 22.04) - that is obviously a different environment, but verified to me that the problem was not with the code.
After finding this report, I confirmed that I could run my code after starting Spyder via the Anaconda PowerShell prompt, and after reinstalling scipy with pip, the code does run in Spyder when started from the Start menu.
The problem never appears in the Python CLI with Spyder installed in the environment.
I did some more testing on my end. Running the following code...:
- works: Running from CLI with Spyder installed environment.
- works: Running from Spyder IPython (launching Spyder by typing 'spyder' at mamba command prompt).
- fails: Running from Spyder IPython (launching Spyder from Windows Start menu shortcut).
Ok, thanks for the additional info @ba05, that's really valuable. This could be related to updates to a package called menuinst
.
@mrclary, could you check if you are able to reproduce this with menuinst
1.4 and 2.0? Thanks!
@ba05 @evanhorn, can you confirm the menuinst
version in your base conda environment?
$ mamba list -n base menusint
@ba05 @evanhorn, can you confirm the
menuinst
version in your base conda environment?$ mamba list -n base menusint
Here you go (Note your commend had a typo, menusint vs menuinst)
# Name Version Build Channel menuinst 1.4.19 py310h5588dad_1 conda-forge
Just to provide information regarding menuinst
:
menuinst <2.0
is in the base conda environment.menuinst >=2.0
is in the base conda environment.I will check to see if existing Spyder versions do anything strange for menuinst >=2.0
. At least for the present issue, I don't think it is the result of menuinst
since @ba05 reported version <2.0.
This is the error I get:
In [1]: import numpy as np
...: import scipy.signal as signal
...: np.cov([1,2,3],[1.1, 2.1, 3]) # works, no error
...: signal.savgol_filter([1,2,3], window_length=2, polyorder=1) # works, no error
Windows fatal exception: code 0xc06d007e
Main thread:
Current thread 0x000020b0 (most recent call first):
File "C:\Users\rclary\.conda\envs\issue-21771\Lib\site-packages\numpy\lib\function_base.py", line 2747 in cov
File "C:\Users\rclary\AppData\Local\Temp\ipykernel_10528\1129720154.py", line 3 in <module>
Restarting kernel...
In [1]:
The shortcut target (for me) is
C:\Users\rclary\AppData\Local\miniforge3\pythonw.exe C:\Users\rclary\AppData\Local\miniforge3\cwp.py C:\Users\rclary\.conda\envs\issue-21771 C:\Users\rclary\.conda\envs\issue-21771\pythonw.exe C:\Users\rclary\.conda\envs\issue-21771\Scripts\spyder-script.py
You can run this from a vanilla cmd terminal and reproduce the error (be sure to replace your correct paths).
At this point, I don't think it is menuinst
, at least not directly. I've done some preliminary investigation and gotten the shortcut to work in some circumstance but not others and don't yet know what to make of it. Is it the environment activation? Is it an issue with pythonw
vs python
? Is it a conda
or python
version? I'm not sure yet. But I'll report back.
I've reproduced the error with our latest master Spyder and menuinst >=2.0
, so this issue will be important to figure out.
It appears the discussion has moved passed suspecting menuinst
, but in case it's helpful, I have menuinst == 1.4.20
installed in my base conda environment.
@evanhorn or @ba05, could you downgrade (if possible) to menuinst
1.4.17, install Spyder and Numpy in a new environment and try again?
This is a comment in an issue reported last week that could help to solve this conundrum:
Not sure if this is a bug... For sure I would not try to repeat this, but somehow after first failing with broken environments but then finally succeeding in updating to conda python 3.10 and latest Spyder 5.4.3 I found myself in the state where Spyder would launch perfectly from my environment, but would crash immediately if launched from the Start Menu. This all on Windows 10. The error message in Event Log pointed me to KERNELBASE.DLL, but that turned out to be a red herring.
If I copied the start menu command and typed it into an Anaconda terminal, then Spyder would launch. If I copied that start menu command into a regular terminal, then Spyder would immediately die with the same KERNELBASE.DLL error reported to the Event log. After hacking around in PDB, I found that the environment being created by CWP.PY was not quite the same environment that did work, specifically it was missing the ....\my-env\bin folder, which has in it LIBIOMP5MD.DLL
I changed CWP.PY to add the term join(prefix, "bin"),
to the new_paths and, amazing, Spyder now opens perfectly from the startup menu.
As I say, I don't know if I had a broken environment somehow, but if anyone else is reporting similar mysterious errors on launch then it might be appropriate to update cwp.py for everyone.
Originally posted by @Tunneller in https://github.com/spyder-ide/spyder/issues/21760#issue-2115442380
@evanhorn or @ba05, could you downgrade (if possible) to
menuinst
1.4.17, install Spyder in a new environment and try again?
Looks like I am unable to downgrade due to not allowing Python 3.12 (which I am running):
warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE
Could not solve for environment specs
The following packages are incompatible
└─ menuinst 1.4.17** is installable with the potential options
├─ menuinst 1.4.17 would require
│ └─ python >=3.6,<3.7.0a0 , which can be installed;
├─ menuinst 1.4.17 would require
│ └─ python >=3.7,<3.8.0a0 , which can be installed;
├─ menuinst 1.4.17 would require
│ └─ python >=3.8,<3.9.0a0 , which can be installed;
└─ menuinst 1.4.17 would require
└─ python >=3.9,<3.10.0a0 , which can be installed.
@Tunneller @ccordoba12, I can corroborate @Tunneller's workaround in #21760. I'll investigate further, but there may actually be a bug in conda
's shell activate as well...
Okay, there is not a bug with conda
's shell activate, but cwp.py
is certainly missing the additional %PREFIX%\bin
path in PATH
. This is likely a bug, since I believe that cwp.py
is intended to replicate the conda run -p
mechanism, which does correctly add that path to PATH
.
Nevertheless, this issue is affecting Spyder's IPython console because Spyder does not activate the conda environment if the console environment is the same as Spyder's runtime environment. The simplest workaround for now is to create a separate conda environment and use that for IPython consoles.
We can fix this problem for 5.x and 6.x moving forward by ensuring that all conda environments are activated in KernelSpec.argv
, not just external ones.
We decided to fix this issue in our next version (5.5.2), to be released in a couple of weeks. In the meantime, please start Spyder from the command line after activating your conda env.
Some commands crash the kernel when run in the Spyder iPython console vs the Python CLI. See https://github.com/ipython/ipython/issues/14266