-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Crash when restarting kernel #17805
Comments
Hey @Gra55h0pper, thanks for reporting. I see that you can run I'm asking because if you installed more packages with pip inside the app, that could have broken it and we can't simply fix that. |
@ccordoba12, I just ran Note that I don't use (mini)conda as my application is implemented in Google App Engine which (I believe) only supports pip with a requirements.txt file. |
@ccordoba12 although the error re: matplotlib import doesn't give any trace information I have a very strong suspicion it's caused by an Intel vs ARM architecture incompatibility. I found that when I enter Is there a way I can install Spyder to run native M1 (arm64)? |
Ok, sorry, you didn't mention that you're using an external environment.
Ok, so does the error go away if you uninstall Matplotlib?
The installer is based on Intel packages because there aren't arm64 available ones for all Spyder dependencies, but that shouldn't be a problem, I think. @mrclary, do you have an M1 laptop available to test this?
Not at the moment, sorry. |
I've got an M1 iMac and will check it out... |
@mrclary Sounds good!! So summarizing, it appears to me that if I point a standalone installed Spyder on a Mac M1 to a Python |
I am unable to reproduce the OP on my M1 iMac.
@Gra55h0pper, Perhaps you could share more details? How did you create your virtual environment? can you share your pip list for that environment? Have you tried rebuilding your virtual environment? pip list
|
To me this looks more like a firewall/VPN issue because the traceback above is related to ZMQ sockets. |
Following @mrclary's finding that it works for him I tried it again (regular arm64 shell) using a "latest everything minimal approach":
...giving me (after pointing Spyder to @mrclary, I noticed the following differences between our setups:
|
Okay, so at least it's reproducible. And, yes, I now see where your Python is coming from...
This is a good question! My bet is on the different Python installation. I have Python installed via |
Hmm... I still don't have any issues. Installed Python from python.org and created a virtual environment exactly as @Gra55h0pper specified. However, @ccordoba12 we should probably ensure that the path selection for the Python interpreter does not resolve the symlink. I navigated to |
Update! Given @mrclary's findings I tried it again but this time using Python 3.9.7 from miniconda:
This works!! Spyder reports:
So I'm guessing some package/link-library on my computer somehow conflicts with Spyder... (?) And using Conda somehow resolves the conflict... (?) I'm wondering if it could be something installed through homebrew??? I have quite a few of these to support other (non-Python) development environments:
|
So looking at the above |
@ccordoba12 Thinking about this, the miniconda workaround should work fine for me actually! It should allow me to So from my perspective we can close this Issue if desired. However if you'd like to debug further to understand better what's going on under the hood I'd be happy to contribute of course!! I really like Spyder and have been using it for several years now! |
Excellent!
I don't think there is any conflict with Spyder. The issue is likely the virtual environment.
This is also unlikely. Homebrew, the virtual environment, your installed Python, and miniconda, all live in different places and don't interact. When you installed Python from python.org, did you also run Also, since I could not actually reproduce the error, I cannot say for sure whether the traceback in the OP is a result of the first kernel shutting down (issue #17615) rather than the virtual environment failing to start (although that was "Socket operation on non-socket" not "Operation not supported"). @Gra55h0pper, if you're so inclined, you could run Spyder in debug mode from the Terminal. $ /Applications/Spyder.app/Contents/MacOS/Spyder --debug-info=verbose Then proceed to engage the "bad" virtual environment and reproduce the OP error and quit Spyder. Then post the file |
Ok, then this could be the problem, i.e. that we're using the wrong Python for venvs. What happens of you leave the resolved symlink? Do you get a similar error as @Gra55h0pper? |
No, I do not get a similar error. In this case the IPython console does not start up and gives the error message regarding missing @Gra55h0pper, can you confirm that the Python executable in your Python Interpreter preference pane is the unresolved path to the virtual environment? If it is not, will you try to force this by pasting or typing the path into the field instead of using the file navigator? If |
Sorry for the radio silence. Had some other things that had priority. I have in the preferences Python interpreter section: Also I tried uninstalling miniconda3 (just to take that variable out of the equation) and installing the 'pass/fail' environments from scratch (pass == 386 (Rosetta) terminal used for install, fail == arm64 terminal):
I then looked at the python executable links:
And compared these to the python executable links for the working (i386) venv:
Seems to be the same. |
I just noticed a difference. The for .venv_pass
for .venv_fail
... but this would be as expected though? |
@Gra55h0pper, I suppose I've misunderstood your setup. How do you work with both arm64 and i386 (Rosetta) terminals? I don't understand this. |
@mrclary, see for example: https://apple.stackexchange.com/questions/428768/on-apple-m1-with-rosetta-how-to-open-entire-terminal-iterm-in-x86-64-architec
So if I (pip)-install spyder-kernels + matplotlib in a venv created in such a Rosetta i386 terminal it works. If I run the same install commands in a regular arm64 terminal it doesn't (matplotlib import error). |
Ahhh. I missed this from the very beginning, I'm sorry.
Okay, I will try to replicate the issue again. Just to be clear the steps are:
and
If this is correct, then I suspect that pip is checking package compatibility against package version requirements only, not platform, but requesting the platform version based on the current Terminal |
Nr. 1 in the second case should read: create a venv using the arm64 terminal. (But I think that's what you meant to say). |
Interesting thought! So I tried (in the non-working (i.e. arm64) terminal+venv):
Spyder then seems to work in the sense that the iPython console does not give the error anymore and The only weird thing is that now the terminal pane inside Spyder (which I hardly ever use to be honest) doesn't seem to initialize properly as it just shows a completely white background (and nothing else). |
...of course I then should have immediately tried to add the same treatment for spyder-kernels:
Works!!! Now I'm curious if you're able to replicate my findings or whether I'd still have something unusual happening on my system... |
So summarizing, I just verified that the following minimal install procedure using All commands executed from a regular MacOS M1 arm64 terminal:
(So simple, I cannot believe I didn't think of trying this before...) |
So, with Spyder 5.3.0 macOS app and the Python installed from python.org (universal2 installer) I've done the following:
numpy tracebackIn [1]: import numpy
Traceback (most recent call last):
File "/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/__init__.py", line 23, in <module>
from . import multiarray
File "/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
from . import overrides
File "/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ImportError: dlopen(/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/folders/sc/1rrvv5750vx9bdrq5cbktybh0000gn/T/ipykernel_54554/2172125874.py", line 1, in <cell line: 1>
import numpy
File "/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
from . import core
File "/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/Users/ryan/arm64env/bin/python"
* The NumPy version is: "1.22.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/ryan/arm64env/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
So, I think I need to investigate a matrix of settings: Spyder = {standalone app, local source}; environment type = {venv (python.org), conda, pyenv}; terminal arch = {i386, arm64} |
This does not appear to be a Spyder issue, but there are some issues related to arm64 architecture for PyQt5.
While I was unable to reproduce the OP, I believe that the core issue was related to architecture incompatibility in the virtual environment, and not Spyder. @spyder-ide/core-developers, I don't believe there is anything for us to do here, unless someone can exert influence with PyQt5 developers to upload arm64 wheels to PyPi. @ccordoba12 do you feel comfortable closing this issue? |
Thanks for the thorough research @mrclary! After reading your post, I also agree there's nothing we can do about it on our side, so I'm going to close this issue. @Gra55h0pper, I think it's better for you to use Conda and Conda-forge, which has now full support for the arm64 architecture on Mac. |
@Gra55h0pper, I realize that you are working on a native arm64 platform but doing development for x86_64 platforms. This may become a more common issue as M1 Macs gain market share among Mac users. At present, as @ccordoba12 says, for developing for arm64, conda-forge is best as it has the best arm64 support. However for developing on arm64 but for x86_64, your solution of using the x86_64 version of the Python universal2 installation is a good one. However, for other users that come across this issue, the key take-away is to remember to not mix platform environments and always prefix python commands with |
Description
What steps will reproduce the problem?
When I select "restart kernel" Spyder crashes.
The crash likely relates to the fact that I cannot get the kernel to properly start in the first place always reporting this error:
"Your Python environment or installation doesn't have the matplotlib module installed or it occurred a problem importing it. Due to that, it is not possible for Spyder to create this special console for you."
Note that I do have matplotlib abd spyder-kernels installed in a Python venv:
% pip list | grep matplotlib
matplotlib 3.5.1
matplotlib-inline 0.1.3
% pip list | grep kernels
spyder-kernels 2.3.0
I'm running on a Mac M1 in ARM64 mode.
Traceback
Versions
Dependencies
The text was updated successfully, but these errors were encountered: