欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何修改Jupyter的工作路径?

程序员文章站 2022-07-14 11:57:42
...

Jupyter介绍

Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。Jupyter Notebook 的本质是一个 Web 应用程序。

1、安装Jupyter只需要一条指令如下:

# conda install jupyter # 安装Jupyter

启动Jupyter

# jupyter notebook                                                                                                                           
[I 21:45:14.550 NotebookApp] The port 8888 is already in use, trying another port.                                                           
[I 21:45:14.976 NotebookApp] Serving notebooks from local directory: C:\Users\Administrator                                                  
[I 21:45:14.976 NotebookApp] 0 active kernels                                                                                                
[I 21:45:14.977 NotebookApp] The Jupyter Notebook is running at:                                                                             
[I 21:45:14.977 NotebookApp] http://localhost:8889/?token=84ecce80c62474e9dfeef199e6046bad7639dd5beb38d57b                                   
[I 21:45:14.977 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).                       
[C 21:45:14.981 NotebookApp]                                                                                                                 

    Copy/paste this URL into your browser when you connect for the first time,                                                               
    to login with a token:                                                                                                                   
        http://localhost:8889/?token=84ecce80c62474e9dfeef199e6046bad7639dd5beb38d57b&token=84ecce80c62474e9dfeef199e6046bad7639dd5beb38d57b 
[I 21:45:15.178 NotebookApp] Accepting one-time-token-authenticated connection from ::1                                                      

1.1、启动完成后可以看到以下界面:
如何修改Jupyter的工作路径?

1.2、修改Jupyter工作目录
使用jupyter notebook –generate-config指令获取当前Jupyter路径

(yankerp) aaa@qq.com C:\Users\Administrator
# jupyter notebook --generate-config
Writing default config to: C:\Users\Administrator\.jupyter\jupyter_notebook_config.py

目前的路径在C:\Users\Administrator.jupyter\jupyter_notebook_config.py

1.3、打开jupyter_notebook_config文件
打开文件找到c.NotebookAppxxxx定义 Jupyter notebook工作路径如下:

c.NotebookApp.notebook_dir = 'C:\\Jupyter-yankerp\jupyter'

在上面的C:\Jupyter-yankerp\jupyter目录需要提前创建
如何修改Jupyter的工作路径?

2、创建Python工作环境验证Jupyter工作目录

2.1、修改完成后重新打开Jupyter创建Python3查看修改后的工作目录是否增加新的环境

如何修改Jupyter的工作路径?

尝试写Python代码随后保存文件打开创建的Jupyter工作目录查看是否有Yankerp文件
如何修改Jupyter的工作路径?

Bye~

相关标签: Jupyter