简体   繁体   English

为什么 Jupyter Notebook 中出现 Kernel 错误?

[英]Why do I have a Kernel Error in Jupyter Notebook?

I am a newbie to python.我是 python 的新手。 I am getting the below error in Kernel while opening jupyter notebook.打开 jupyter notebook 时,我在 Kernel 中收到以下错误。 Any ideas how I can resolve it?有什么想法可以解决吗? Installation of jupyter has been done via Anaconda3 - tried reinstalling and setting environment variables, but no luck so far. jupyter 的安装是通过 Anaconda3 完成的 - 尝试重新安装和设置环境变量,但到目前为止没有运气。 Any help would be greatly appreciated.任何帮助将不胜感激。

 Traceback (most recent call last):
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
        result = await result
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
        type=mtype))
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
        self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
        yielded = next(result)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
        self.write_connection_file()
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
        kernel_name=self.kernel_name
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
        with secure_write(fname) as f:
      File "C:\Users\drag88\Anaconda3\lib\contextlib.py", line 112, in __enter__
        return next(self.gen)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
        win32_restrict_file_to_user(fname)
      File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
        import win32api
    ImportError: DLL load failed: The specified procedure could not be found.

It looks like you had installed jupyter when there was an issue with its dependencies on Windows.当它对 Windows 的依赖存在问题时,您似乎已经安装了 jupyter。 See https://github.com/jupyterlab/jupyterlab/issues/7259 .请参阅https://github.com/jupyterlab/jupyterlab/issues/7259 I ran into the same error.我遇到了同样的错误。

It should be fixed on conda now, so if you uninstall and reinstall jupyterlab from conda, it should not throw that error anymore.它现在应该在 conda 上修复,所以如果你从 conda 卸载并重新安装 jupyterlab,它不应该再抛出那个错误了。

  • Step 2 command: conda activate (location of your env folder)第 2 步命令: conda activate (location of your env folder)
  • Step 3 command: python -m ipykernel install --user第三步命令: python -m ipykernel install --user

Works for Windows.适用于 Windows。

If you have Python installed on your pc run from cmd or powershell:如果您的电脑上安装了 Python,请从 cmd 或 powershell 运行:

pip install jupyterlab

Then you can start it with:然后你可以开始它:

jupyter lab

The installation might have missed some steps which are fixed by post_install.安装可能错过了一些由 post_install 修复的步骤。 Go to yout venv's Script directory and run the command Go 到你的 venv 的 Script 目录并运行命令

python .\pywin32_postinstall.py -install

Make sure you are running the shell with Admin rights.确保您使用管理员权限运行 shell。

This error is sometimes as a result of the deleted environment that was created before.此错误有时是由于之前创建的已删除环境造成的。 For Windows users, run the following code in cmd对于 Windows 用户,在 cmd 中运行以下代码

python -m ipykernel install –user python -m ipykernel install –user

I battled to get Jupyter working on my Windows 10 office computer for a number of hours.我努力让 Jupyter 在我的 Windows 10 办公计算机上工作了几个小时。 This was after installing Anaconda3.这是在安装 Anaconda3 之后。 I had versions of Python 2 and 3 installed before.我之前安装了 Python 2 和 3 的版本。 I was getting 'Kernel error' and also had various errors about 'win32api' and 'tornado'我收到“内核错误”并且还有关于“win32api”和“龙卷风”的各种错误

I did many things but in the end main ones that, I think, helped are listed below -我做了很多事情,但最终我认为有帮助的主要内容如下所列 -

On install, Anaconda3 created a data folder here -安装时,Anaconda3 在这里创建了一个数据文件夹 -

C:\ProgramData\Anaconda3

I gave my user account access to write to this folder, I am not sure if it made a difference.我授予我的用户帐户写入此文件夹的权限,我不确定它是否有所作为。

Elevated to admin, I copied two dll files as below -提升为管理员,我复制了两个 dll 文件如下 -

pythoncom39.dll
pywintypes39.dll

From -从 -

C:\ProgramData\Anaconda3\Lib\site-packages\pywin32_system32

To -至 -

C:\windows\system32

At the 'Anaconda Prompt', a Windows cmd screen (which was added to my start menu) after the install, I did this -在安装后的“Anaconda Prompt”,一个 Windows cmd 屏幕(已添加到我的开始菜单),我这样做了 -

(base) C:\> conda env create test-env (基础)C:\> conda conda env create test-env

It created 'test-env' folder at C:\Users\{windows user name}\.conda\envs\test-env它在 C:\Users\{windows 用户名}\.conda\envs\test-env 创建了“test-env”文件夹

(base) C:\> conda activate "C:\Users\{windows user name}\.conda\envs\test-env" (基础)C:\> conda conda activate "C:\Users\{windows user name}\.conda\envs\test-env"

(test-env) C:\> (测试环境) C:\>

Once in this newly created environment, I tried various other things such as these -一旦在这个新创建的环境中,我尝试了各种其他的东西,比如这些 -

conda install jupyter
conda install pywin32
python -m ipykernal install --user

Launching jupyter after loading and setting to this environment now works by using this command -现在可以使用以下命令在加载并设置到此环境后启动 jupyter -

(test-env) C:\> jupyter notebook (test-env) C:\> jupyter notebook

When browser opens, select New>python 3 (ipykernel) from right hand menu to create new notebook.当浏览器打开时,select New>python 3 (ipykernel) 从右侧菜单创建新笔记本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每次运行 jupyter 笔记本时,我是否必须重新启动 kernel? - do i have to restart the kernel everytime I run a jupyter notebook? Jupyter 笔记本中的内核错误,我也尝试删除内核 - Kernel error in Jupyter notebook and i have tried deleting the kernels as well Jupyter Notebook kernel 安装错误 - Jupyter Notebook kernel installation error 我的 Jupyter 笔记本显示错误“连接到内核”。 我不知道该怎么办? - My Jupyter notebook shows an error 'connecting to kernel '. I dont know what to do? 如何在我的jupyter笔记本中添加python3内核? - How do I add a python3 kernel to my jupyter notebook? 如何在 IPython (Jupyter) Notebook 的远程机器上添加 kernel? - How do I add a kernel on a remote machine in IPython (Jupyter) Notebook? 当我打开 Jupyter Notebook 时,出现 Kernel 错误 - When I open Jupyter Notebook there is a Kernel Error appears jupyter笔记本中的kernel错误有什么解决方案(我在我的系统中安装了jupyter笔记本) - is there any solution for kernel error in jupyter notebook(i installed jupyter notebook in mysystem) 如何让 jupyter 笔记本使用正确的 kernel? - How to have a jupyter notebook use the correct kernel? 为什么每次打开 Jupyter Notebook 时都必须在 Anaconda 中重新安装 scikit learn? - Why do I have to reinstall scikit learn in Anaconda each time I open up my Jupyter Notebook?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM