欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jupyter notebook: Import error (zmq: Can not launch jupyter notebook)

程序员文章站 2022-06-01 09:26:46
...

点赞发Nature
关注中Science

问题:新装了一个anaconda虚拟环境,进而安装了jupyter notebook组件。但是发现无法从anaconda prompt启动jupyter notebook,报错(cannot connet to kernel balabala)如下:

Traceback (most recent call last):
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。
[I 00:24:44.250 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
Traceback (most recent call last):
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。
[I 00:24:47.252 NotebookApp] KernelRestarter: restarting kernel (2/5), keep random ports
Traceback (most recent call last):
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。
[I 00:24:50.276 NotebookApp] KernelRestarter: restarting kernel (3/5), keep random ports
Traceback (most recent call last):
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。
[I 00:24:53.313 NotebookApp] KernelRestarter: restarting kernel (4/5), keep random ports
Traceback (most recent call last):
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "D:\Users\sheep\Anaconda3\envs\fcLCA\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。

解决办法:
从报错信息看是zmq库的问题,重新安装zmq库:

pip uninstall pyzmq
pip install pyzmq

办法从GitHub获取

相关标签: 其他工具