Jupyter Notebook未连接到python内核

时间:2019-02-07 19:04:31

标签: anaconda ipython

我以前从python.org安装了python 3.7,后来又安装了anaconda python发行版。当我启动Jupyter笔记本时,内核无法连接。我尝试重新安装但可能无法解决问题。

下面是我得到的错误。

 [I 00:23:53.252 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\ipykernel\connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\IPython\__init__.py", line 54, in <module>
    from .core.application import Application
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\IPython\core\application.py", line 25, in <module>
    from IPython.core import release, crashhandler
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\IPython\core\crashhandler.py", line 27, in <module>
    from IPython.core import ultratb
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\IPython\core\ultratb.py", line 115, in <module>
    from IPython.core import debugger
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\IPython\core\debugger.py", line 47, in <module>
    from pdb import Pdb as OldPdb
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\pdb.py", line 76, in <module>
    import code
  File "C:\Users\lenovo\Desktop\HW1_Q1\code.py", line 5, in <module>
    "execution_count": null,
NameError: name 'null' is not defined
[W 00:23:56.368 NotebookApp] KernelRestarter: restart failed
[W 00:23:56.368 NotebookApp] Kernel 3087f4f8-f452-476b-becc-41f53a23cf80 died, removing from map.

1 个答案:

答案 0 :(得分:0)

  • 创建一个conda环境,
  • 使用conda在其中安装Python + Jupyter,
  • 激活conda环境

Conda确保已安装的组件可以组合在一起。例如,在Linux操作系统上,安装了多个Python

此外, 您可以在不指定文件的情况下运行jupyter notebook吗?