Windows下的Jupyter Notebook 安装与自定义启动(图文详解)
小编注:如果不是特殊需要建议安装 anaconda3 即可,自带jupyter notebook 。
手动安装之前建议查看这篇文章:
这是我自定义的python 的安装目录 (d:\software\python\python36\scripts)
1、jupyter notebook 和 pip
为了更加方便地写 python 代码,还需要安装 jupyter notebook。 利用 pip 安装 jupyter notebook。
为什么要使用 jupyter?参考:
pip: python 的包管理工具,安装 python 的同时已经安装好了。
jupyter notebook: 一个交互式笔记本,支持运行 40 多种编程语言。 利用她来写 python,代码和运行结果都可以保存下载,十分方便。
2、jupyter notebook 安装
命令行窗口输入: pip install jupyter
切换到 d:\software\python\python36\scripts目录下,
当然,若大家是默认安装的话,则在c:\users\administrator\appdata\local\programs\python\python36\scripts 目录下 。
或者将该目录添加到 path,就不用切换了。
我这里,因为考虑到机器学习深度学习那边,已经安装了anaconda2和anaconda3,所以这边的数据分析所用的python3.6.1就不添加到path了。每次去切换到这个目录来,也不麻烦。
microsoft windows [版本 6.1.7601]
版权所有 (c) 2009 microsoft corporation。保留所有权利。c:\users\administrator>cd /d d:\
d:\>cd d:\software\python\python36\scripts
d:\software\python\python36\scripts>pip install jupyter
安装成功。
3、 jupyter notebook的启动
命令行窗口输入: jupyter notebook
d:\software\python\python36\scripts>jupyter notebook
[i 10:37:02.828 notebookapp] serving notebooks from local directory: d:\software
\python\python36\scripts
[i 10:37:02.828 notebookapp] 0 active kernels
[i 10:37:02.828 notebookapp] the jupyter notebook is running at: http://localhos
t:8888/?token=8f82159edecad826ce9769f126402fc58f5b87b8d1050b0d
[i 10:37:02.829 notebookapp] use control-c to stop this server and shut down all
kernels (twice to skip confirmation).
[c 10:37:02.833 notebookapp]copy/paste this url into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=8f82159edecad826ce9769f126402fc58f5b87b8d10
50b0d
[i 10:37:03.628 notebookapp] 302 get / (::1) 1.00ms
[i 10:37:03.647 notebookapp] 302 get /tree? (::1) 5.00ms
[i 10:37:05.535 notebookapp] accepting one-time-token-authenticated connection f
rom ::1
同时,默认浏览器会打开 jupyter notebook 窗口。 说明 jupyter notebook 安装成功了。
4、配置 jupyter notebook
jupyter notebook --generate-config
运行之前
打开“.jupyter”文件夹,可以看到里面有个配置文件。
microsoft windows [版本 6.1.7601]
版权所有 (c) 2009 microsoft corporation。保留所有权利。c:\users\administrator>cd /d d:\
d:\>cd d:\software\python\python36\scripts
d:\software\python\python36\scripts>jupyter notebook --generate-config
writing default config to: c:\users\administrator\.jupyter\jupyter_notebook_conf
ig.pyd:\software\python\python36\scripts>
修改jupyter_notebook_config.py配置文件
打开这个配置文件,找到“c.notebookapp.notebook_dir=……”,把路径改成自己的工作目录。
比如,这里要变更为
## the directory to use for notebooks and kernels.
c.notebookapp.notebook_dir = 'd:\code\jupyter-notebook'
,当然,文件夹 jupyter-notebook 需要自己创建好。
配置文件修改完成后, 以后在 jupyter notebook 中写的代码等都会保存在自己创建的目录中。
jupyter notebook的自定义启动(变了)
配置文件修改成后,就可以启动 jupyter notebook 了,命令行窗口中输入 jupyter notebook,
默认浏览器就会打开一个页面
jupyter notebook的启动
命令行窗口输入: jupyter notebook
以前是
d:\software\python\python36\scripts>jupyter notebook
[i 10:37:02.828 notebookapp] serving notebooks from local directory: d:\software
\python\python36\scripts
[i 10:37:02.828 notebookapp] 0 active kernels
[i 10:37:02.828 notebookapp] the jupyter notebook is running at: http://localhos
t:8888/?token=8f82159edecad826ce9769f126402fc58f5b87b8d1050b0d
[i 10:37:02.829 notebookapp] use control-c to stop this server and shut down all
kernels (twice to skip confirmation).
[c 10:37:02.833 notebookapp]copy/paste this url into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=8f82159edecad826ce9769f126402fc58f5b87b8d10
50b0d
[i 10:37:03.628 notebookapp] 302 get / (::1) 1.00ms
[i 10:37:03.647 notebookapp] 302 get /tree? (::1) 5.00ms
[i 10:37:05.535 notebookapp] accepting one-time-token-authenticated connection f
rom ::1
现在是
microsoft windows [版本 6.1.7601]
版权所有 (c) 2009 microsoft corporation。保留所有权利。c:\users\administrator>cd /d d:\
d:\>cd d:\software\python\python36\scripts
d:\software\python\python36\scripts>jupyter notebook
[i 10:59:58.326 notebookapp] serving notebooks from local directory: d:\code\jup
yter-notebook
[i 10:59:58.327 notebookapp] 0 active kernels
[i 10:59:58.327 notebookapp] the jupyter notebook is running at: http://localhos
t:8888/?token=e520d165636db926b824bd77fe81559555ff679cc5fdc774
[i 10:59:58.328 notebookapp] use control-c to stop this server and shut down all
kernels (twice to skip confirmation).
[c 10:59:58.332 notebookapp]copy/paste this url into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=e520d165636db926b824bd77fe81559555ff679cc5f
dc774
[i 10:59:59.532 notebookapp] accepting one-time-token-authenticated connection f
rom ::1
当然,其实啊,这个玩意非常的简单和方便。关于修改名字、上传等操作
常见问题及解决方案
如何添加 path?
计算机-右击-单机“属性”
单机“高级系统设置”
常见问题及解决方案
如何添加 path?
计算机-右击-单机“属性”
单机“高级系统设置”
单机“环境变量”
找到系统变量 path,编辑
在最后加上 2 个路径:
c:\users\administrator\appdata\local\programs\python\python36
c:\users\administrator\appdata\local\programs\python\python36\scripts
说明:以上默认安装路径,每个电脑上是类似的,找到复制这个路径加到 path 中即可
我的路径是已经改了
jupyter notebook 闪退问题
解决办法:更换默认浏览器。 ,建议用谷歌浏览器或者火狐浏览器