【问题标题】:Jupyter Notebook - Cannot Connect to KernelJupyter Notebook - 无法连接到内核
【发布时间】:2019-07-24 03:09:39
【问题描述】:

我尝试使用 pip3 install jupyter 安装 jupyter notebook。每次我启动一个新的 jupyter 笔记本时,笔记本都无法连接到内核。请参阅下面的屏幕截图附加我的 requirements.txt 文件,我也在 Python 版本 3.6.8 上。 Jupyter 版本是 4.4.0,笔记本版本是 5.7.4。

我在哪里出错了,我该如何解决这个问题?谢谢!

attrs==18.2.0
backcall==0.1.0
bleach==3.1.0
colorama==0.4.1
cycler==0.10.0
decorator==4.3.2
defusedxml==0.5.0
entrypoints==0.3
ipykernel==5.1.0
ipython==7.3.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.0.1
MarkupSafe==1.1.1
matplotlib==3.0.3
mistune==0.8.4
nbconvert==5.4.1
nbformat==4.4.0
notebook==5.7.4
numpy==1.16.2
pandas==0.24.1
pandocfilters==1.4.2
parso==0.3.4
pickleshare==0.7.5
prometheus-client==0.6.0
prompt-toolkit==2.0.9
Pygments==2.3.1
pyparsing==2.3.1
pyrsistent==0.14.11
python-dateutil==2.8.0
pytz==2018.9
pywinpty==0.5.5
pyzmq==18.0.0
qtconsole==4.4.3
scikit-learn==0.20.3
scipy==1.2.1
seaborn==0.9.0
Send2Trash==1.5.0
six==1.12.0
sklearn==0.0
terminado==0.8.1
testpath==0.4.2
tornado==6.0
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2

例子

【问题讨论】:

  • Windows --> 更改代理设置 --> 自动检测设置 -> “关闭”

标签: jupyter-notebook


【解决方案1】:

pip install jupytext --upgrade 为我工作。

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
【解决方案2】:

这在 Python 3.7 下对我有用。

pip3 install tornado==5.1.1
pip3 install notebook==5.7.4

【讨论】:

  • 这为我解决了!!!经过几天寻找解决方案......
【解决方案3】:

我的做法类似于@AzizNal@delx的回答。

我将此问题的具体表现跟踪到以下内容:

  • 我想保留一堆杂项语句,并将它们保存在文件./myworkingdirectory/random.py 中。

  • 我试图在与该文件所在目录相同的目录中打开的任何笔记本都无法连接到内核。

    (同样,任何以myworkingdirectory 工作方向打开的 Spyder 环境都会崩溃并且无法连接到内核)

  • 仔细检查错误告诉我numpy: cannot import name SystemRandom

鉴于上述情况,我认为我的这个random.py 与其他一些random.py 冲突。删除或重命名文件解决了这个问题。

【讨论】:

  • 我遇到了类似的问题。我的情况是我的“.ipynb”文件的同一文件夹中有一个名为“email.py”的文件。由于 'email' 是一个标准模块,所以我需要将我的 'email.py' 命名为另一个名称,例如 'play_email.py',只要新名称与任何标准模块名称不同即可。详情请参考https://groups.google.com/g/jupyter/c/TZwqNstDBRs
【解决方案4】:

对于仍然存在此问题的任何人,造成此问题的主要原因之一是您的存储空间不足。尝试删除一些文件以腾出空间。

【讨论】:

    【解决方案5】:

    我也曾经遇到过这个问题,但对我来说,这发生在我尝试从工作目录以外的其他文件位置打开 .ipynb 文件时。但这是通过将所需文件移动到我的工作目录来解决的。

    因此,对于您的问题,只需确保您启动的新笔记本是否在您的工作目录中。

    【讨论】:

      【解决方案6】:

      如果上述方法对您不起作用,那么强烈推荐。

      我遇到了同样的问题,内核根本无法连接。尝试了所有解决方案,仍然没有连接。

      最后,我注意到在我启动笔记本客户端的控制台中引发了一些值错误异常。这些异常的来源是与 notebook 位于同一文件夹中的另一个 python 脚本。

      删除安装笔记本的同一目录中的所有python文件或将它们移动到其他文件夹。修复笔记本

      【讨论】:

      • 非常感谢!这个解决方案是我一直在寻找的解决方案
      【解决方案7】:

      我在转换成 Ubuntu 20.04 服务器的旧 PC 上遇到了类似的问题,Jupyterlab 在 Jupyterhub 下运行。 使用以下命令安装 Jupytext 后出现问题:

      python3 -m pip install jupytext --upgrade
      

      其中不仅安装了 Jupytext,而且还将我的系统升级到了 Jupyterlab 2.2.9 和 Jupyterhub 1.2.2(以及其他软件包更新)。

      之后,运行一个包含简单代码的单元格:

      3 * 4
      

      在任何 python 3.6 内核甚至 R 3.6 或 4.0 内核下都会给我留下状态消息:

      内核 xxx 正在连接...

      但从未完成连接或简单计算。

      重新安装Tornado到5.1.1版本,也没有重新安装ipywidgets,都没有成功解决问题。

      但最终将 Jupyterlab 和 Jupyterhub 降级到(大约)原始版本号对我有用:

      python3 -m pip install wheel jupyterhub==1.1.0 jupyterlab==2.1.0 ipywidgets
      

      根据命令输出,实际应用了以下包版本:

      Installing collected packages: wheel, jupyterhub
        Attempting uninstall: wheel
          Found existing installation: wheel 0.34.2
          Uninstalling wheel-0.34.2:
            Successfully uninstalled wheel-0.34.2
        Attempting uninstall: jupyterhub
          Found existing installation: jupyterhub 1.1.0
          Uninstalling jupyterhub-1.1.0:
            Successfully uninstalled jupyterhub-1.1.0
      Successfully installed jupyterhub-1.2.2 wheel-0.36.1
      

      重新启动 jupyterhub 后,我所有的内核都再次工作了。

      【讨论】:

        【解决方案8】:

        我收到了这个错误:

        from prompt_toolkit.eventloop import generator_to_async_generator
        ImportError: cannot import name 'generator_to_async_generator' from 'prompt_toolkit.eventloop' (/Users/danielmlow/miniconda3/envs/pydra/lib/python3.7/site-packages/prompt_toolkit/eventloop/__init__.py)
        

        于是我升级了prompt_toolkit:

        pip install prompt_toolkit==3.0.
        

        【讨论】:

          【解决方案9】:

          我遇到了同样的问题,内核根本无法连接。尝试了所有解决方案,仍然没有连接。

          最后,我注意到在我启动 jupyter 客户端的控制台中引发了一些 ValueError 异常。 这些异常的来源是与 notebook 位于同一文件夹中的另一个 python 脚本。

          修正了脚本。修复了笔记本。

          【讨论】:

            【解决方案10】:

            我只是重新启动了 Anaconda 程序并打开了一个新的 Python 3 笔记本,Jupyter 就可以连接了。 :)

            【讨论】:

              【解决方案11】:

              使用以下方法创建 conda 环境:

              conda create -n my_env python=3
              

              使用以下方法激活环境:

              source activate my_env
              

              使用以下命令安装 ipykernel:

              conda install ipykernel
              
              ipython kernel install --name my_env --user
              

              现在打开 jupyter 并从 Kernel 选项中选择“my_env”。 (路径:jupyter -> 内核 -> 更改内核 -> my_env)

              【讨论】:

                【解决方案12】:

                只需更新笔记本,应该可以工作

                【讨论】:

                  【解决方案13】:

                  就我而言,我刚刚更新了我的 jupyter 并且它工作了。

                  【讨论】:

                    【解决方案14】:

                    适用于 linux 和 windows:

                         just install ipython kernel
                    
                               "python3 -m pip install ipykernel"
                    
                               "python3 -m ipykernel install --user"
                    
                          then restart jupyter notebook that's it
                    

                    【讨论】:

                    • 请分享更多代码来解释你的答案。
                    【解决方案15】:

                    您最近可能已将 Tornado 更新到 6.0.0。尝试将其重新安装到版本 5.1.1。它只是帮助了我。浪费了 1 小时宝贵的周六时间。

                    【讨论】:

                    • 谢谢,我检查了一下,看起来 Tornado 6.0 是在 pip 安装 jupyter 时默认出现的。我能够卸载,但我无法执行 pip install tornado 5.1.1。有什么建议?它回来说找不到满足5.1.1要求的版本。
                    • 啊,没关系。我使用了错误的语法。我使用 pip install tornado==5.1.1 和 wala!现在我可以再次连接到 jupyter notebook。这是龙卷风 6.0 上的错误吗? jupyter 不适用于 tornado 6.0 并且默认安装,这似乎很奇怪。
                    • 很高兴我们都能弄清楚!感谢@Elena 发现了这个问题。只是为了进一步的文档,我发现这是许多人最近报告的常见问题。 github.com/jupyter/jupyter/issues/401
                    • @DavisVickers 很高兴听到它有帮助。对我来说,不清楚这个错误是在龙卷风还是在 jupyter 方面。我所知道的是,当我用最新版本更新龙卷风时,问题就出现了。
                    • 安装 5.1.1 版后出现此错误notebook 6.4.4 requires tornado>=6.1, but you have tornado 5.1.1 which is incompatible
                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 2020-12-21
                    • 1970-01-01
                    • 2019-07-27
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多