一、准备

确保pip为最新版本,老版本可能存在一些依赖问题。

pip3 install --upgrade pip

二、安装

使用以下命令安装jupyter。

pip3 install jupyter

三、升级

方法一、使用Anaconda升级jupyter。

conda update jupyter

方法二、使用pip升级jupyter。

pip install -U jupyter

四、运行

使用以下命令运行jupyter服务。

jupyter notebook

控制台会打印jupyter服务URL(默认为 http://localhost:8888),使用该URL即可进入jupyter web编辑器。

[I 08:58:24.417 NotebookApp] Serving notebooks from local directory: /Users/catherine
[I 08:58:24.417 NotebookApp] 0 active kernels
[I 08:58:24.417 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 08:58:24.417 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

五、允许远程访问

为了安全考虑,默认jupyter服务只能本地(127.0.0.1 or localhost)访问,怎样可以远程访问呢?可以通过以下设置。

# 生成jupyter配置
jupyter notebook --generate-config

修改jupyter配置如下(将c.NotebookApp.ip修改为本机ip或者域名):

vim ~/.jupyter/jupyter_notebook_config.py

在这里插入图片描述
修改之后再次启动jupyter服务就可以远程访问了(前提服务器相应防火墙必须放开)。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐