2023-07-26 08:41:40 +08:00
|
|
|
|
[#]: subject: "How to Install Jupyter Notebook in Debian or Ubuntu Linux"
|
|
|
|
|
[#]: via: "https://www.debugpoint.com/install-jupyter-ubuntu/"
|
|
|
|
|
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
|
|
|
|
[#]: collector: "lkxed"
|
|
|
|
|
[#]: translator: "geekpi"
|
2023-07-28 06:38:49 +08:00
|
|
|
|
[#]: reviewer: "wxy"
|
|
|
|
|
[#]: publisher: "wxy"
|
|
|
|
|
[#]: url: "https://linux.cn/article-16040-1.html"
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
如何在 Linux 中安装 Jupyter Notebook
|
2023-07-26 08:41:40 +08:00
|
|
|
|
======
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
![][0]
|
|
|
|
|
|
|
|
|
|
> 如何在 Ubuntu 或 Debian Linux 中安装 Jupyter Notebook 的简单教程。
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
[Jupyter][1] Notebook 是一款功能强大的基于 Web 的交互式开发工具,可让你创建和共享实时代码、可视化和交互式数据。其笔记本格式结合了代码和文本,使其成为数据探索、分析和协作项目的绝佳选择。
|
|
|
|
|
|
|
|
|
|
在本教程中,我们将逐步指导你在基于 Ubuntu 或 Debian 的系统上安装 Jupyter Notebook,使你能够利用其多功能性并扩展编程能力。
|
|
|
|
|
|
|
|
|
|
### 安装 pip
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
在开始之前,请确保你的系统上已安装 `pip`(Python 包安装程序)。如果你已经安装了 `pip`,则可以跳过此步骤。否则,请按照以下说明进行安装。你还可以访问 [此页面][2] 获取详细说明。
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
打开终端窗口(`Ctrl+Alt+T`)并输入以下命令,按回车键:
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sudo apt updatesudo apt install python3-pip
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
系统可能会提示你输入密码。提供它并等待安装完成。
|
|
|
|
|
|
|
|
|
|
### 安装 virtualenv
|
|
|
|
|
|
|
|
|
|
尽管不是强制性的,但建议在 Jupyter Notebook 安装中通过此工具隔离你的工作环境。这可以确保你安装的任何更改或软件包都不会干扰系统的 Python 环境。要设置虚拟环境,请按照以下步骤操作:
|
|
|
|
|
|
|
|
|
|
在终端中,输入以下命令:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sudo apt install python3-virtualenv
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
等待安装完成。完成后,继续下一步。
|
|
|
|
|
|
|
|
|
|
### 创建虚拟环境
|
|
|
|
|
|
|
|
|
|
创建虚拟环境是一个简单的过程。以下是专门为 Jupyter Notebook 设置新虚拟环境的方法:
|
|
|
|
|
|
|
|
|
|
进入到要在其中创建虚拟环境的目录。在终端中运行以下命令:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
virtualenv my-jupyter-env
|
|
|
|
|
```
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
此命令创建一个名为 `my-jupyter-env` 的新目录,其中将包含虚拟环境文件。
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
![create jupyter environment][3]
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
你还可以通过任何文件管理器验证该目录是否在你的主文件夹下创建成功。
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
![jupyter env folders][4]
|
|
|
|
|
|
|
|
|
|
输入以下命令激活虚拟环境:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
source my-jupyter-env/bin/activate
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
你会注意到终端提示符发生变化,表明你现在位于虚拟环境中。
|
|
|
|
|
|
|
|
|
|
![activate the environment][5]
|
|
|
|
|
|
|
|
|
|
### 安装 Jupyter Notebook
|
|
|
|
|
|
|
|
|
|
激活虚拟环境后,你现在可以继续安装 Jupyter Notebook:
|
|
|
|
|
|
|
|
|
|
在终端中,输入以下命令:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pip install jupyter
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
此命令会获取必要的包并在虚拟环境中安装 Jupyter Notebook。
|
|
|
|
|
|
|
|
|
|
![Installing jupyter using pip][6]
|
|
|
|
|
|
|
|
|
|
### 启动 Jupyter Notebook
|
|
|
|
|
|
|
|
|
|
安装完成后,你就可以启动 Jupyter Notebook:
|
|
|
|
|
|
|
|
|
|
在终端中,输入以下命令:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
jupyter notebook
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
执行命令后,Jupyter Notebook 将启动,你应该看到类似于以下内容的输出:
|
|
|
|
|
|
|
|
|
|
![running jupyter notebook in Debian][7]
|
|
|
|
|
|
|
|
|
|
你的默认 Web 浏览器将打开,显示 Jupyter Notebook 界面。
|
|
|
|
|
|
|
|
|
|
![Jupyter notebook running in browser][8]
|
|
|
|
|
|
|
|
|
|
### 关闭并重新启动
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
如果要关闭 Notebook 服务器,请确保关闭并保存所有笔记。关闭浏览器。然后在终端窗口中按 `CTRL+C`。它会提示你是否要关闭服务器。输入 `Yes` 并按回车键。最后,关闭终端窗口。
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
要再次重新启动服务器,你需要按上面的描述运行 `virtualenv my-jupyter-env` 等所有命令
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
### 总结
|
|
|
|
|
|
|
|
|
|
恭喜! 你已在 Ubuntu 或 Debian 系统上成功安装 Jupyter Notebook。通过执行上述步骤,你现在可以利用 Jupyter 的交互式开发环境轻松编写代码、创建可视化并探索数据。
|
|
|
|
|
|
|
|
|
|
请记住,Jupyter Notebook 支持各种编程语言,包括 Python,并提供大量插件来进一步扩展其功能。
|
|
|
|
|
|
2023-07-28 06:38:49 +08:00
|
|
|
|
*(题图:MJ/e3436c7f-435d-491e-9032-b945730cb000)*
|
|
|
|
|
|
2023-07-26 08:41:40 +08:00
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
via: https://www.debugpoint.com/install-jupyter-ubuntu/
|
|
|
|
|
|
|
|
|
|
作者:[Arindam][a]
|
|
|
|
|
选题:[lkxed][b]
|
|
|
|
|
译者:[geekpi](https://github.com/geekpi)
|
2023-07-28 06:38:49 +08:00
|
|
|
|
校对:[wxy](https://github.com/wxy)
|
2023-07-26 08:41:40 +08:00
|
|
|
|
|
|
|
|
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
|
|
|
|
|
|
|
|
[a]: https://www.debugpoint.com/author/admin1/
|
|
|
|
|
[b]: https://github.com/lkxed/
|
|
|
|
|
[1]: https://jupyter.org/
|
|
|
|
|
[2]: https://www.debugpoint.com/pip-command-not-found/
|
|
|
|
|
[3]: https://www.debugpoint.com/wp-content/uploads/2023/07/create-jupyter-environment.jpg
|
|
|
|
|
[4]: https://www.debugpoint.com/wp-content/uploads/2023/07/jupyter-env-folders.jpg
|
|
|
|
|
[5]: https://www.debugpoint.com/wp-content/uploads/2023/07/active-the-environment.jpg
|
|
|
|
|
[6]: https://www.debugpoint.com/wp-content/uploads/2023/07/Installing-jupyter-using-pip.jpg
|
|
|
|
|
[7]: https://www.debugpoint.com/wp-content/uploads/2023/07/running-jupyter-notebook-in-Debian.jpg
|
|
|
|
|
[8]: https://www.debugpoint.com/wp-content/uploads/2023/07/Jupyter-notebook-running-in-browser.jpg
|
2023-07-28 06:38:49 +08:00
|
|
|
|
[0]: https://img.linux.net.cn/data/attachment/album/202307/28/063430e6lz9elvz4pw55l4.jpg
|