Python | 如何修改Jupyter的工作路径?

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、启动完成后可以看到以下界面:
Python | 如何修改Jupyter的工作路径?_第1张图片

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

(yankerp) Administrator@MZNOQLGC1WJQ0RT 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目录需要提前创建
Python | 如何修改Jupyter的工作路径?_第2张图片

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

Python | 如何修改Jupyter的工作路径?_第3张图片

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

Bye~

你可能感兴趣的:(Python,Python全栈开发之路)