jupyter notebook 用 onedrive实现多端同步

2020-09-01
思路是把jupyter notebook的默认运行目录移动到onedrive中,参考
https://www.jianshu.com/p/50989327da1e?tdsourcetag=s_pcqq_aiomsg

1. 创建配置文件jupyter_notebook_config.py

根据网上的说法,第一步是在cmd运行一个命令。
在搜索栏搜索cmd,打开后输入命令

jupyter notebook --generate-config

然而我输入后提示:"jupyter' 不是内部或外部命令,也不是可运行的程序


image.png

解决方法参考了以下链接:
https://www.cnblogs.com/coolcold/p/9859619.html
搜索栏搜索anaconda ,打开anaconda prompt,输入该命令,成功:

image.png

2. 在配置文件中修改默认目录

之后到上文Writing default config to的这个目录找到该文件,并修改内容。
用记事本打开该文件,Ctrl+F搜索,搜索dir,知道找到下面这句话。

## The directory to use for notebooks and kernels.
# c.NotebookApp.notebook_dir = ''

填入需要的路径,即onedrive底下的任意目录。删去开头的#。
注意使用双反斜杠:
(亲测使用单正斜杠不行,会导致jupyter notebook 闪退)

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'C:\\Users\\YourUserName\\OneDrive\\AnywhereYouLike'

3. 修改快捷方式:

找到jupyer notebook的快捷方式:


image.png

打开该快捷方式的属性并修改:
【目标】中去掉 %USERPROFILE%部分
【起始位置】删掉所有内容,我这里就是删掉%HOMEPATH%


image.png

然后就OK了。再次打开jupyter notebook 会发现已经是新设置的目录下了。

另一台电脑也同样操作。onedrive自动同步,即可自动同步jupyter notebook中的内容。

你可能感兴趣的:(jupyter notebook 用 onedrive实现多端同步)