Python Jupyter:无法创建新笔记本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34851801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:36:48  来源:igfitidea点击:

Jupyter: can't create new notebook?

pythonipython-notebookjupyterjupyter-notebook

提问by Richard

I have some existing Python code that I want to convert to a Jupyter notebook. I have run:

我有一些现有的 Python 代码,我想将其转换为 Jupyter 笔记本。我跑了:

jupyter notebook

Now I can see this in my browser:

现在我可以在浏览器中看到这个:

enter image description here

在此处输入图片说明

But how do I create a new notebook? The Notebooklink in the menu is greyed out, and I can't see any other options to create a new notebook.

但是我如何创建一个新的笔记本呢?Notebook菜单中的链接变灰,我看不到任何其他创建新笔记本的选项。

I've noticed this on the command line while Jupyter is running:

我在 Jupyter 运行时在命令行上注意到了这一点:

[W 22:30:08.128 NotebookApp] Native kernel (python2) is not available 

采纳答案by Alex Riley

It looks like you don't have an IPython kernel installed (or any other kernel for that matter!).

看起来您没有安装 IPython 内核(或任何其他内核!)。

There are various ways (old versions, new versions) to do this. One of the simplest ways is to use pip. From the command line enter:

有多种方法(旧版本新版本)可以做到这一点。最简单的方法之一是使用 pip。从命令行输入:

pip install ipython

You may also need to register the kernel with Jupyter (see the new versionspage):

您可能还需要向 Jupyter 注册内核(请参阅新版本页面):

python -m pip install ipykernel

python -m ipykernel install [--user] [--name <machine-readable-name>] [--display-name <"User Friendly Name">]

You should now be able to launch a Python notebook from Jupyter.

您现在应该可以从 Jupyter 启动 Python notebook。

Alternatively, installing Jupyter using any of the methods on this pageshould ensure that the IPython kernel is already there. Personally, Anaconda has always just worked out of the box for me (when I've used it on Linux and Mac OS).

或者,使用此页面上的任何方法安装 Jupyter应确保 IPython 内核已经存在。就个人而言,Anaconda 对我来说总是开箱即用(当我在 Linux 和 Mac OS 上使用它时)。

回答by dangirsh

None of the other answers worked for me on Ubuntu 14.04. After 2 days of struggling, I finally realized that I needed to install the latest version of IPython (not the one in pip). First, I uninstalled ipython from my system with:

在 Ubuntu 14.04 上,其他答案都不适合我。经过2天的挣扎,我终于意识到我需要安装最新版本的IPython(而不是pip中的那个)。首先,我从我的系统中卸载了 ipython:

sudo apt-get --purge remove ipython
sudo pip uninstall ipython

I don't know if you need both, but both did something on my system.

我不知道你是否需要两者,但两者都在我的系统上做了一些事情。

Then, I installed ipython from source like this:

然后,我从这样的源安装了 ipython:

git clone https://github.com/ipython/ipython.git
cd ipython
sudo pip install -e . 

Note the period at the end of the last line. After this, I reran jupyter notebook and the python2 kernel was detected!

请注意最后一行末尾的句点。在此之后,我重新运行 jupyter notebook 并检测到 python2 内核!

回答by El Rakone

I had the same problem, it is because I installed ipython with sudo apt-get -y install ipython ipython-notebookinstead of sudo pip install ipython. Therefore, uninstall all ipython stuff using: sudo apt-get --purge remove ipython sudo pip uninstall ipython

我遇到了同样的问题,这是因为我安装了 ipythonsudo apt-get -y install ipython ipython-notebook而不是sudo pip install ipython. 因此,使用以下命令卸载所有 ipython 内容: sudo apt-get --purge remove ipython sudo pip uninstall ipython

and then install it with pip

然后用pip安装

回答by smishra

I had similar issue but looks like this its because I was using python 2.7. I was able to launch notebook by clicking on "Python 2"dropdown option.

我有类似的问题,但看起来像这样,因为我使用的是python 2.7。我可以通过单击“Python 2”下拉选项来启动笔记本。

回答by devil in the detail

I was also getting the same error. My error snapshot is here. Following below solved my problem:

我也遇到了同样的错误。我的错误快照在这里。以下解决了我的问题:

  1. sudo apt-get -y install ipython ipython-notebook
  2. sudo -H pip install jupyter
  1. sudo apt-get -y install ipython ipython-notebook
  2. sudo -H pip install jupyter

It was not working because I was getting 0active kernel message and this came because I installed jupyter using step2 only (skipped step1).

它不起作用,因为我收到了0活动的内核消息,这是因为我仅使用 step2 安装了 jupyter(跳过了 step1)。

回答by Msingh

If anyone is still having this issue, for me it was solved by running

如果有人仍然遇到这个问题,对我来说它是通过运行解决的

pip install --upgrade ipykernel

回答by u6462737

because ipython version is too new. you can use follow commands

因为 ipython 版本太新了。您可以使用以下命令

pip uninstall ipython
pip install ipython==5.1

回答by Jan ?imbera

Also, check if you have cookies enabled in your browser. Without cookies, the listing of the directory appears empty, as does the notebook creation menu.

此外,请检查您的浏览器是否启用了 cookie。没有 cookie,目录列表显示为空,笔记本创建菜单也是如此。

回答by nishant.babel

For me the error was:

对我来说,错误是:

ERROR: notebook 6.0.0 has requirement tornado>=5.0, but you'll have tornado 4.5.3 which is incompatible.

错误:笔记本 6.0.0 要求 tornado>=5.0,但您将拥有不兼容的 tornado 4.5.3。

I solved it by following the below steps:

我按照以下步骤解决了它:

pip uninstall ipykernel
pip install --upgrade tornado
pip install ipykernel

Now open jupyter notebook from terminal. It should work fine.

现在从终端打开 jupyter notebook。它应该可以正常工作。