Infinite loading when importing libraries

Hi!
I am facing some issues when importing libraries, as the cell will stay loading [*] and never end. When I start the notebook I can run any python code that doesn’t require external libraries, I can also import numpy, but importing scikit or matplot will end up in this never ending loading cell, that results in a dead kernel.

I have already tried recreating the environment and installing ipykernel to be able to choose the conda environment from the notebook, but it gives the same error. The libraries I am trying to import work perfectly on the environment using the terminal, and I just get this issue when using the notebook. I’ve also tried to import non-installed packages, and for those I do get an output saying that the package doesn’t exist.

I am running macOS 13.0.1 with M1 and conda 22.9.0

Jupyter-troubleshoot returns this:

$PATH:
	/opt/homebrew/opt/jpeg/bin
	/Users/johndoe/mambaforge/envs/envname/bin
	/Users/johndoe/mambaforge/condabin
	/opt/homebrew/bin
	/opt/homebrew/sbin
	/usr/local/bin
	/System/Cryptexes/App/usr/bin
	/usr/bin
	/bin
	/usr/sbin
	/sbin
	/Library/TeX/texbin
	/Library/Frameworks/Mono.framework/Versions/Current/Commands

sys.path:
	/Users/johndoe/mambaforge/envs/envname/bin
	/Users/johndoe/mambaforge/envs/envname/lib/python310.zip
	/Users/johndoe/mambaforge/envs/envname/lib/python3.10
	/Users/johndoe/mambaforge/envs/envname/lib/python3.10/lib-dynload
	/Users/johndoe/mambaforge/envs/envname/lib/python3.10/site-packages

sys.executable:
	/Users/johndoe/mambaforge/envs/envname/bin/python

sys.version:
	3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:25:29) [Clang 14.0.6 ]

platform.platform():
	macOS-13.0.1-arm64-arm-64bit

which -a jupyter:
	/Users/johndoe/mambaforge/envs/envname/bin/jupyter

pip list:
	Package                       Version
	----------------------------- -----------
	anyio                         3.6.2
	appnope                       0.1.3
	argon2-cffi                   21.3.0
	argon2-cffi-bindings          21.2.0
	asttokens                     2.2.1
	attrs                         22.1.0
	backcall                      0.2.0
	backports.functools-lru-cache 1.6.4
	beautifulsoup4                4.11.1
	bleach                        5.0.1
	cffi                          1.15.1
	debugpy                       1.6.4
	decorator                     5.1.1
	defusedxml                    0.7.1
	entrypoints                   0.4
	executing                     1.2.0
	fastjsonschema                2.16.2
	flit_core                     3.8.0
	idna                          3.4
	importlib-metadata            5.1.0
	importlib-resources           5.10.1
	ipykernel                     6.17.1
	ipython                       8.7.0
	ipython-genutils              0.2.0
	ipywidgets                    8.0.3
	jedi                          0.18.2
	Jinja2                        3.1.2
	joblib                        1.2.0
	jsonschema                    4.17.3
	jupyter                       1.0.0
	jupyter_client                7.4.8
	jupyter-console               6.4.4
	jupyter_core                  5.1.0
	jupyter-events                0.5.0
	jupyter_server                2.0.0
	jupyter_server_terminals      0.4.2
	jupyterlab-pygments           0.2.2
	jupyterlab-widgets            3.0.4
	MarkupSafe                    2.1.1
	matplotlib-inline             0.1.6
	mistune                       2.0.4
	nbclassic                     0.4.8
	nbclient                      0.7.2
	nbconvert                     7.2.6
	nbformat                      5.7.0
	nest-asyncio                  1.5.6
	notebook                      6.5.2
	notebook_shim                 0.2.2
	numpy                         1.23.5
	packaging                     21.3
	pandocfilters                 1.5.0
	parso                         0.8.3
	pexpect                       4.8.0
	pickleshare                   0.7.5
	pip                           22.3.1
	pkgutil_resolve_name          1.3.10
	platformdirs                  2.5.2
	prometheus-client             0.15.0
	prompt-toolkit                3.0.36
	psutil                        5.9.4
	ptyprocess                    0.7.0
	pure-eval                     0.2.2
	pycparser                     2.21
	Pygments                      2.13.0
	pyparsing                     3.0.9
	pyrsistent                    0.19.2
	python-dateutil               2.8.2
	python-json-logger            2.0.1
	PyYAML                        6.0
	pyzmq                         24.0.1
	scikit-learn                  1.1.3
	scipy                         1.9.3
	Send2Trash                    1.8.0
	setuptools                    65.5.1
	six                           1.16.0
	sniffio                       1.3.0
	soupsieve                     2.3.2.post1
	stack-data                    0.6.2
	terminado                     0.17.1
	threadpoolctl                 3.1.0
	tinycss2                      1.2.1
	tornado                       6.2
	traitlets                     5.6.0
	typing_extensions             4.4.0
	wcwidth                       0.2.5
	webencodings                  0.5.1
	websocket-client              1.4.2
	wheel                         0.38.4
	widgetsnbextension            4.0.4
	zipp                          3.11.0

conda list:
	# packages in environment at /Users/johndoe/mambaforge/envs/envname:
	#
	# Name                    Version                   Build  Channel
	_ipython_minor_entry_point 8.7.0                hb6b4a82_0    conda-forge
	anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
	appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
	argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
	argon2-cffi-bindings      21.2.0          py310h8e9501a_3    conda-forge
	asttokens                 2.2.1              pyhd8ed1ab_0    conda-forge
	attrs                     22.1.0             pyh71513ae_1    conda-forge
	backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
	backports                 1.0                pyhd8ed1ab_3    conda-forge
	backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
	beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
	bleach                    5.0.1              pyhd8ed1ab_0    conda-forge
	bzip2                     1.0.8                h3422bc3_4    conda-forge
	ca-certificates           2022.9.24            h4653dfc_0    conda-forge
	cffi                      1.15.1          py310h2399d43_2    conda-forge
	debugpy                   1.6.4           py310h0f1eb42_0    conda-forge
	decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
	defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
	entrypoints               0.4                pyhd8ed1ab_0    conda-forge
	executing                 1.2.0              pyhd8ed1ab_0    conda-forge
	flit-core                 3.8.0              pyhd8ed1ab_0    conda-forge
	idna                      3.4                pyhd8ed1ab_0    conda-forge
	importlib-metadata        5.1.0              pyha770c72_0    conda-forge
	importlib_resources       5.10.1             pyhd8ed1ab_0    conda-forge
	ipykernel                 6.17.1             pyh736e0ef_0    conda-forge
	ipython                   8.7.0              pyhd1c38e8_0    conda-forge
	ipython_genutils          0.2.0                      py_1    conda-forge
	ipywidgets                8.0.3              pyhd8ed1ab_0    conda-forge
	jedi                      0.18.2             pyhd8ed1ab_0    conda-forge
	jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
	joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
	jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
	jupyter                   1.0.0           py310hbe9552e_8    conda-forge
	jupyter_client            7.4.8              pyhd8ed1ab_0    conda-forge
	jupyter_console           6.4.4              pyhd8ed1ab_0    conda-forge
	jupyter_core              5.1.0           py310hbe9552e_0    conda-forge
	jupyter_events            0.5.0              pyhd8ed1ab_0    conda-forge
	jupyter_server            2.0.0              pyhd8ed1ab_0    conda-forge
	jupyter_server_terminals  0.4.2              pyhd8ed1ab_0    conda-forge
	jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
	jupyterlab_widgets        3.0.4              pyhd8ed1ab_0    conda-forge
	libblas                   3.9.0           16_osxarm64_openblas    conda-forge
	libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
	libcxx                    14.0.6               h2692d47_0    conda-forge
	libffi                    3.4.2                h3422bc3_5    conda-forge
	libgfortran               5.0.0           11_3_0_hd922786_26    conda-forge
	libgfortran5              11.3.0              hdaf2cc0_26    conda-forge
	liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
	libopenblas               0.3.21          openmp_hc731615_3    conda-forge
	libsodium                 1.0.18               h27ca646_1    conda-forge
	libsqlite                 3.40.0               h76d750c_0    conda-forge
	libzlib                   1.2.13               h03a7124_4    conda-forge
	llvm-openmp               15.0.6               h7cfbb63_0    conda-forge
	markupsafe                2.1.1           py310h8e9501a_2    conda-forge
	matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
	mistune                   2.0.4              pyhd8ed1ab_0    conda-forge
	nbclassic                 0.4.8              pyhd8ed1ab_0    conda-forge
	nbclient                  0.7.2              pyhd8ed1ab_0    conda-forge
	nbconvert                 7.2.6              pyhd8ed1ab_0    conda-forge
	nbconvert-core            7.2.6              pyhd8ed1ab_0    conda-forge
	nbconvert-pandoc          7.2.6              pyhd8ed1ab_0    conda-forge
	nbformat                  5.7.0              pyhd8ed1ab_0    conda-forge
	ncurses                   6.3                  h07bb92c_1    conda-forge
	nest-asyncio              1.5.6              pyhd8ed1ab_0    conda-forge
	notebook                  6.5.2              pyha770c72_1    conda-forge
	notebook-shim             0.2.2              pyhd8ed1ab_0    conda-forge
	numpy                     1.23.5          py310h5d7c261_0    conda-forge
	openssl                   3.0.7                h03a7124_1    conda-forge
	packaging                 21.3               pyhd8ed1ab_0    conda-forge
	pandoc                    2.19.2               hce30654_1    conda-forge
	pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
	parso                     0.8.3              pyhd8ed1ab_0    conda-forge
	pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
	pickleshare               0.7.5                   py_1003    conda-forge
	pip                       22.3.1             pyhd8ed1ab_0    conda-forge
	pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
	platformdirs              2.5.2              pyhd8ed1ab_1    conda-forge
	prometheus_client         0.15.0             pyhd8ed1ab_0    conda-forge
	prompt-toolkit            3.0.36             pyha770c72_0    conda-forge
	prompt_toolkit            3.0.36               hd8ed1ab_0    conda-forge
	psutil                    5.9.4           py310h8e9501a_0    conda-forge
	ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
	pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
	pycparser                 2.21               pyhd8ed1ab_0    conda-forge
	pygments                  2.13.0             pyhd8ed1ab_0    conda-forge
	pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
	pyrsistent                0.19.2          py310h8e9501a_0    conda-forge
	python                    3.10.8          h3ba56d0_0_cpython    conda-forge
	python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
	python-fastjsonschema     2.16.2             pyhd8ed1ab_0    conda-forge
	python-json-logger        2.0.1              pyh9f0ad1d_0    conda-forge
	python_abi                3.10                    3_cp310    conda-forge
	pyyaml                    6.0             py310h8e9501a_5    conda-forge
	pyzmq                     24.0.1          py310hc407298_1    conda-forge
	readline                  8.1.2                h46ed386_0    conda-forge
	scikit-learn              1.1.3           py310ha00a7cd_1    conda-forge
	scipy                     1.9.3           py310ha0d8a01_2    conda-forge
	send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
	setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
	six                       1.16.0             pyh6c4a22f_0    conda-forge
	sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
	soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
	stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
	terminado                 0.17.1             pyhd1c38e8_0    conda-forge
	threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
	tinycss2                  1.2.1              pyhd8ed1ab_0    conda-forge
	tk                        8.6.12               he1e0b03_0    conda-forge
	tornado                   6.2             py310h8e9501a_1    conda-forge
	traitlets                 5.6.0              pyhd8ed1ab_0    conda-forge
	typing_extensions         4.4.0              pyha770c72_0    conda-forge
	tzdata                    2022g                h191b570_0    conda-forge
	wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
	webencodings              0.5.1                      py_1    conda-forge
	websocket-client          1.4.2              pyhd8ed1ab_0    conda-forge
	wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
	widgetsnbextension        4.0.4              pyhd8ed1ab_0    conda-forge
	xz                        5.2.6                h57fd34a_0    conda-forge
	yaml                      0.2.5                h3422bc3_2    conda-forge
	zeromq                    4.3.4                hbdafb3b_1    conda-forge
	zipp                      3.11.0             pyhd8ed1ab_0    conda-forge

conda env:
	name: envname
	channels:
	  - conda-forge
	dependencies:
	  - _ipython_minor_entry_point=8.7.0=hb6b4a82_0
	  - anyio=3.6.2=pyhd8ed1ab_0
	  - appnope=0.1.3=pyhd8ed1ab_0
	  - argon2-cffi=21.3.0=pyhd8ed1ab_0
	  - argon2-cffi-bindings=21.2.0=py310h8e9501a_3
	  - asttokens=2.2.1=pyhd8ed1ab_0
	  - attrs=22.1.0=pyh71513ae_1
	  - backcall=0.2.0=pyh9f0ad1d_0
	  - backports=1.0=pyhd8ed1ab_3
	  - backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
	  - beautifulsoup4=4.11.1=pyha770c72_0
	  - bleach=5.0.1=pyhd8ed1ab_0
	  - bzip2=1.0.8=h3422bc3_4
	  - ca-certificates=2022.9.24=h4653dfc_0
	  - cffi=1.15.1=py310h2399d43_2
	  - debugpy=1.6.4=py310h0f1eb42_0
	  - decorator=5.1.1=pyhd8ed1ab_0
	  - defusedxml=0.7.1=pyhd8ed1ab_0
	  - entrypoints=0.4=pyhd8ed1ab_0
	  - executing=1.2.0=pyhd8ed1ab_0
	  - flit-core=3.8.0=pyhd8ed1ab_0
	  - idna=3.4=pyhd8ed1ab_0
	  - importlib-metadata=5.1.0=pyha770c72_0
	  - importlib_resources=5.10.1=pyhd8ed1ab_0
	  - ipykernel=6.17.1=pyh736e0ef_0
	  - ipython=8.7.0=pyhd1c38e8_0
	  - ipython_genutils=0.2.0=py_1
	  - ipywidgets=8.0.3=pyhd8ed1ab_0
	  - jedi=0.18.2=pyhd8ed1ab_0
	  - jinja2=3.1.2=pyhd8ed1ab_1
	  - joblib=1.2.0=pyhd8ed1ab_0
	  - jsonschema=4.17.3=pyhd8ed1ab_0
	  - jupyter=1.0.0=py310hbe9552e_8
	  - jupyter_client=7.4.8=pyhd8ed1ab_0
	  - jupyter_console=6.4.4=pyhd8ed1ab_0
	  - jupyter_core=5.1.0=py310hbe9552e_0
	  - jupyter_events=0.5.0=pyhd8ed1ab_0
	  - jupyter_server=2.0.0=pyhd8ed1ab_0
	  - jupyter_server_terminals=0.4.2=pyhd8ed1ab_0
	  - jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
	  - jupyterlab_widgets=3.0.4=pyhd8ed1ab_0
	  - libblas=3.9.0=16_osxarm64_openblas
	  - libcblas=3.9.0=16_osxarm64_openblas
	  - libcxx=14.0.6=h2692d47_0
	  - libffi=3.4.2=h3422bc3_5
	  - libgfortran=5.0.0=11_3_0_hd922786_26
	  - libgfortran5=11.3.0=hdaf2cc0_26
	  - liblapack=3.9.0=16_osxarm64_openblas
	  - libopenblas=0.3.21=openmp_hc731615_3
	  - libsodium=1.0.18=h27ca646_1
	  - libsqlite=3.40.0=h76d750c_0
	  - libzlib=1.2.13=h03a7124_4
	  - llvm-openmp=15.0.6=h7cfbb63_0
	  - markupsafe=2.1.1=py310h8e9501a_2
	  - matplotlib-inline=0.1.6=pyhd8ed1ab_0
	  - mistune=2.0.4=pyhd8ed1ab_0
	  - nbclassic=0.4.8=pyhd8ed1ab_0
	  - nbclient=0.7.2=pyhd8ed1ab_0
	  - nbconvert=7.2.6=pyhd8ed1ab_0
	  - nbconvert-core=7.2.6=pyhd8ed1ab_0
	  - nbconvert-pandoc=7.2.6=pyhd8ed1ab_0
	  - nbformat=5.7.0=pyhd8ed1ab_0
	  - ncurses=6.3=h07bb92c_1
	  - nest-asyncio=1.5.6=pyhd8ed1ab_0
	  - notebook=6.5.2=pyha770c72_1
	  - notebook-shim=0.2.2=pyhd8ed1ab_0
	  - numpy=1.23.5=py310h5d7c261_0
	  - openssl=3.0.7=h03a7124_1
	  - packaging=21.3=pyhd8ed1ab_0
	  - pandoc=2.19.2=hce30654_1
	  - pandocfilters=1.5.0=pyhd8ed1ab_0
	  - parso=0.8.3=pyhd8ed1ab_0
	  - pexpect=4.8.0=pyh1a96a4e_2
	  - pickleshare=0.7.5=py_1003
	  - pip=22.3.1=pyhd8ed1ab_0
	  - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_0
	  - platformdirs=2.5.2=pyhd8ed1ab_1
	  - prometheus_client=0.15.0=pyhd8ed1ab_0
	  - prompt-toolkit=3.0.36=pyha770c72_0
	  - prompt_toolkit=3.0.36=hd8ed1ab_0
	  - psutil=5.9.4=py310h8e9501a_0
	  - ptyprocess=0.7.0=pyhd3deb0d_0
	  - pure_eval=0.2.2=pyhd8ed1ab_0
	  - pycparser=2.21=pyhd8ed1ab_0
	  - pygments=2.13.0=pyhd8ed1ab_0
	  - pyparsing=3.0.9=pyhd8ed1ab_0
	  - pyrsistent=0.19.2=py310h8e9501a_0
	  - python=3.10.8=h3ba56d0_0_cpython
	  - python-dateutil=2.8.2=pyhd8ed1ab_0
	  - python-fastjsonschema=2.16.2=pyhd8ed1ab_0
	  - python-json-logger=2.0.1=pyh9f0ad1d_0
	  - python_abi=3.10=3_cp310
	  - pyyaml=6.0=py310h8e9501a_5
	  - pyzmq=24.0.1=py310hc407298_1
	  - readline=8.1.2=h46ed386_0
	  - scikit-learn=1.1.3=py310ha00a7cd_1
	  - scipy=1.9.3=py310ha0d8a01_2
	  - send2trash=1.8.0=pyhd8ed1ab_0
	  - setuptools=65.5.1=pyhd8ed1ab_0
	  - six=1.16.0=pyh6c4a22f_0
	  - sniffio=1.3.0=pyhd8ed1ab_0
	  - soupsieve=2.3.2.post1=pyhd8ed1ab_0
	  - stack_data=0.6.2=pyhd8ed1ab_0
	  - terminado=0.17.1=pyhd1c38e8_0
	  - threadpoolctl=3.1.0=pyh8a188c0_0
	  - tinycss2=1.2.1=pyhd8ed1ab_0
	  - tk=8.6.12=he1e0b03_0
	  - tornado=6.2=py310h8e9501a_1
	  - traitlets=5.6.0=pyhd8ed1ab_0
	  - typing_extensions=4.4.0=pyha770c72_0
	  - tzdata=2022g=h191b570_0
	  - wcwidth=0.2.5=pyh9f0ad1d_2
	  - webencodings=0.5.1=py_1
	  - websocket-client=1.4.2=pyhd8ed1ab_0
	  - wheel=0.38.4=pyhd8ed1ab_0
	  - widgetsnbextension=4.0.4=pyhd8ed1ab_0
	  - xz=5.2.6=h57fd34a_0
	  - yaml=0.2.5=h3422bc3_2
	  - zeromq=4.3.4=hbdafb3b_1
	  - zipp=3.11.0=pyhd8ed1ab_0
	prefix: /Users/johndoe/mambaforge/envs/envname

remove your env, install with python 3.10, then install jupyter with mamba, not with a pip, and install packages that you mentioned with mamba as well

Okay, so I did exactly that with the following commands:

>> conda create -n jupyter python=3.10

>> conda activate jupyter
>> conda install -c conda-forge jupyterlab
>> conda install -c conda-forge numpy
>> conda install -c conda-forge scikit-learn
>> conda install -c conda-forge matplotlib

and the issue still persists after launching Jupyter-lab and opening a notebook that has more libraries than numpy. I checked the output of conda install, and it seems to be installing the correct libraries for the m1 as packages are prepended with “conda-forge/osx-arm64”.

The issue is still the same, if I run anything on the terminal, it’ll work, but on the notebook it won’t finish importing the libraries:

Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:25:29) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.datasets import load_breast_cancer
>>> X, y = load_breast_cancer(return_X_y=True)
>>> X
array([[1.799e+01, 1.038e+01, 1.228e+02, ..., 2.654e-01, 4.601e-01,
        1.189e-01],
       [2.057e+01, 1.777e+01, 1.329e+02, ..., 1.860e-01, 2.750e-01,
        8.902e-02],
       [1.969e+01, 2.125e+01, 1.300e+02, ..., 2.430e-01, 3.613e-01,
        8.758e-02],
       ...,
       [1.660e+01, 2.808e+01, 1.083e+02, ..., 1.418e-01, 2.218e-01,
        7.820e-02],
       [2.060e+01, 2.933e+01, 1.401e+02, ..., 2.650e-01, 4.087e-01,
        1.240e-01],
       [7.760e+00, 2.454e+01, 4.792e+01, ..., 0.000e+00, 2.871e-01,
        7.039e-02]])
>>> y
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
       0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0,
       1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0,
       1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
       1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0,
       0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1,
       1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0,
       1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1,
       1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0,
       0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,
       0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0,
       1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1,
       1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1,
       1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
       1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
       1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1,
       1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1])

and this is the output in the notebook:

Also, I just realised that executing commands like %conda list will also have the same problem.

You can save some time, and get a more reproducible environment by creating/checking in an environment.yml:

# environment.yml
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python >=3.10,<3.11
  - jupyterlab
  - numpy
  - scikit-learn
  - matplotlib-base # avoid qt if you can, if having trouble

then, ideally use mamba (win/fail faster, better error messages):

mamba env update -n jupyter --file environment.yml

If you’re still seeing issues, try scaling back the dependencies and rebuild (e.g. start with just jupyterlab and python) in the attempt to bisect what might be causing the issue.

Some other things that would help:

  • a (redacted) log of a minimal kernel startup/run that demonstrates the condition
  • the output of conda info (or mamba info)
  • the output of conda list (or mamba list)

I’ve tried, and I get the same problem. First I created the environment using the environment.yml you recommended and then I dropped matplotlib-base to try with scikit-learn, but the never ending loading cell still happens when importing scikit.

Creating the environment with only jupyterlab and python, and then running %pip list or %conda list in an empty notebook, also has the same problem of a never ending cell.

I don’t know which logs to share tbh, as the terminal doesn’t print any errors, it seems everything is working as usual, so unless there’s a debug mode or sth I am not aware of, it just shows the usual logs of kernel started/restarted/shutdown when I request such actions from the notebook and the usual saves.

conda info

     active environment : jupyter
    active env location : /Users/johndoe/mambaforge/envs/jupyter
            shell level : 2
       user config file : /Users/johndoe/.condarc
 populated config files : /Users/johndoe/mambaforge/.condarc
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.10.6.final.0
       virtual packages : __archspec=1=arm64
                          __osx=13.0.1=0
                          __unix=0=0
       base environment : /Users/johndoe/mambaforge  (writable)
      conda av data dir : /Users/johndoe/mambaforge/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/johndoe/mambaforge/pkgs
                          /Users/johndoe/.conda/pkgs
       envs directories : /Users/johndoe/mambaforge/envs
                          /Users/johndoe/.conda/envs
               platform : osx-arm64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.10.6 Darwin/22.1.0 OSX/13.0.1
                UID:GID : 501:20
             netrc file : None
           offline mode : False

conda list

# packages in environment at /Users/johndoe/mambaforge/envs/jupyter:
#
# Name                    Version                   Build  Channel
_ipython_minor_entry_point 8.7.0                hb6b4a82_0    conda-forge
anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py310h8e9501a_3    conda-forge
asttokens                 2.2.1              pyhd8ed1ab_0    conda-forge
attrs                     22.1.0             pyh71513ae_1    conda-forge
babel                     2.11.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
bleach                    5.0.1              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py310h8e9501a_1005    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2022.12.7            h4653dfc_0    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py310h2399d43_2    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
comm                      0.1.1              pyhd8ed1ab_0    conda-forge
cryptography              38.0.4          py310hfc83b78_0    conda-forge
debugpy                   1.6.4           py310h0f1eb42_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 1.2.0              pyhd8ed1ab_0    conda-forge
flit-core                 3.8.0              pyhd8ed1ab_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        5.1.0              pyha770c72_0    conda-forge
importlib_resources       5.10.1             pyhd8ed1ab_0    conda-forge
ipykernel                 6.19.0             pyh736e0ef_0    conda-forge
ipython                   8.7.0              pyhd1c38e8_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.18.2             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
jupyter_client            7.4.8              pyhd8ed1ab_0    conda-forge
jupyter_core              5.1.0           py310hbe9552e_0    conda-forge
jupyter_events            0.5.0              pyhd8ed1ab_0    conda-forge
jupyter_server            2.0.0              pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.4.2              pyhd8ed1ab_0    conda-forge
jupyterlab                3.5.1              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_server         2.16.3             pyhd8ed1ab_0    conda-forge
libcxx                    14.0.6               h2692d47_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libsodium                 1.0.18               h27ca646_1    conda-forge
libsqlite                 3.40.0               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
markupsafe                2.1.1           py310h8e9501a_2    conda-forge
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
mistune                   2.0.4              pyhd8ed1ab_0    conda-forge
nbclassic                 0.4.8              pyhd8ed1ab_0    conda-forge
nbclient                  0.7.2              pyhd8ed1ab_0    conda-forge
nbconvert                 7.2.6              pyhd8ed1ab_0    conda-forge
nbconvert-core            7.2.6              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.2.6              pyhd8ed1ab_0    conda-forge
nbformat                  5.7.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
nest-asyncio              1.5.6              pyhd8ed1ab_0    conda-forge
notebook                  6.5.2              pyha770c72_1    conda-forge
notebook-shim             0.2.2              pyhd8ed1ab_0    conda-forge
openssl                   3.0.7                h03a7124_1    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandoc                    2.19.2               hce30654_1    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.2              pyhd8ed1ab_1    conda-forge
prometheus_client         0.15.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.36             pyha770c72_0    conda-forge
psutil                    5.9.4           py310h8e9501a_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.13.0             pyhd8ed1ab_0    conda-forge
pyopenssl                 22.1.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.2          py310h8e9501a_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.10.8          h3ba56d0_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.16.2             pyhd8ed1ab_0    conda-forge
python-json-logger        2.0.1              pyh9f0ad1d_0    conda-forge
python_abi                3.10                    3_cp310    conda-forge
pytz                      2022.6             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py310h8e9501a_5    conda-forge
pyzmq                     24.0.1          py310hc407298_1    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_1    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
terminado                 0.17.1             pyhd1c38e8_0    conda-forge
tinycss2                  1.2.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tornado                   6.2             py310h8e9501a_1    conda-forge
traitlets                 5.6.0              pyhd8ed1ab_0    conda-forge
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
urllib3                   1.26.13            pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.4.2              pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
yaml                      0.2.5                h3422bc3_2    conda-forge
zeromq                    4.3.4                hbdafb3b_1    conda-forge
zipp                      3.11.0             pyhd8ed1ab_0    conda-forge

I’ve also tried to use a completely clean install of macOS, and then install mamba and create a Jupyter environment with this exact environment.yml

channels:
  - conda-forge
  - nodefaults
dependencies:
  - python >=3.10,<3.11
  - jupyterlab
  - numpy
  - scikit-learn
  - matplotlib-base

and I am having the same problem again, the terminal doesn’t show any error at all aside the usual logging when opening a notebook, shutting down a kernel or restarting it…

If anyone is facing this issue, I downgraded to python 3.9 and I am no longer facing this problem.

I ran into the same issue today. Was there any other resolution other than a downgrade from python 3.10 to 3.9? This seems to be limited to Jupyter - imports are fine in python & ipython terminal sessions.

I have the same issue with python 3.9 when I try to import a py file. It gets forever to import it.
Update: it seems that I have this issue when I run vscode as user with my miniforge env installed for all users. It seems to be a permission issue.