spyder: Crash when restarting kernel

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

Traceback (most recent call last):
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/ipythonconsole/widgets/client.py", line 681, in _restart_thread_main
    self.shellwidget.kernel_manager.restart_kernel(
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 26, in wrapped
    raise e
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 23, in wrapped
    return loop.run_until_complete(future)
  File "nest_asyncio.pyc", line 81, in run_until_complete
  File "asyncio/futures.pyc", line 201, in result
  File "asyncio/tasks.pyc", line 256, in __step
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 525, in _async_restart_kernel
    await ensure_async(self.shutdown_kernel(now=now, restart=True))
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 26, in wrapped
    raise e
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 23, in wrapped
    return loop.run_until_complete(future)
  File "nest_asyncio.pyc", line 81, in run_until_complete
  File "asyncio/futures.pyc", line 201, in result
  File "asyncio/tasks.pyc", line 256, in __step
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 79, in wrapper
    raise e
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 71, in wrapper
    out = await method(self, *args, **kwargs)
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 486, in _async_shutdown_kernel
    await ensure_async(self.request_shutdown(restart=restart))
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 26, in wrapped
    raise e
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/utils.py", line 23, in wrapped
    return loop.run_until_complete(future)
  File "nest_asyncio.pyc", line 81, in run_until_complete
  File "asyncio/futures.pyc", line 201, in result
  File "asyncio/tasks.pyc", line 256, in __step
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 391, in _async_request_shutdown
    self._connect_control_socket()
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/manager.py", line 312, in _connect_control_socket
    self._control_socket = self._create_connected_socket("control")
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/jupyter_client/connect.py", line 605, in _create_connected_socket
    sock = self.context.socket(socket_type)
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/zmq/sugar/context.py", line 262, in socket
    raise ZMQError(ENOTSUP)
zmq.error.ZMQError: Operation not supported

Versions

  • Spyder version: 5.3.0
  • Python version: 3.9.5
  • Qt version: 5.15.2
  • PyQt5 version: 5.15.6
  • Operating System: Darwin 21.4.0

Dependencies

# Mandatory:
applaunchservices >=0.1.7            :  0.2.1 (OK)
atomicwrites >=1.2.0                 :  1.4.0 (OK)
chardet >=2.0.0                      :  4.0.0 (OK)
cloudpickle >=0.5.0                  :  2.0.0 (OK)
cookiecutter >=1.6.0                 :  1.7.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree >=3.0.2                 :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0              :  7.32.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.4.0 (OK)
keyring >=17.0.0                     :  23.5.0 (OK)
nbconvert >=4.0                      :  6.4.5 (OK)
numpydoc >=0.6.0                     :  1.2.1 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.0 (OK)
pygments >=2.0                       :  2.11.2 (OK)
pylint >=2.5.0                       :  2.13.3 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.0 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.0.1                         :  2.0.1 (OK)
rtree >=0.9.7                        :  0.9.7 (OK)
setuptools >=49.6.0                  :  60.10.0 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.0;<2.4.0        :  2.3.0 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog >=0.10.3                    :  2.1.7 (OK)
zmq >=17                             :  22.3.0 (OK)

# Optional:
cython >=0.21                        :  0.29.28 (OK)
matplotlib >=3.0.0                   :  3.5.1 (OK)
numpy >=1.7                          :  1.22.3 (OK)
pandas >=1.1.1                       :  1.4.1 (OK)
scipy >=0.17.0                       :  1.8.0 (OK)
sympy >=0.7.3                        :  1.10.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30 (16 by maintainers)

Most upvoted comments

@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 arch -x86_64. Hopefully, more universal2 wheels will become available to keep pace with the M1 adoption and obviate the need to create dedicated -x86_64 environments for development.

I just ran pip list in the venv where I have the python interpreter installed (Python 3.10.4) and where I installed spyder-kernels also (using pip install)

Ok, sorry, you didn’t mention that you’re using an external environment.

In the process of trying to fix that I ran into the Spyder crash when selecting restart kernel.

Ok, so does the error go away if you uninstall Matplotlib?

I found that when I enter arch in the Spyder terminal it reports i386 where I had expected the online installer to give me arm64

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?

Is there a way I can install Spyder to run native M1 (arm64)?

Not at the moment, sorry.