0
点赞
收藏
分享

微信扫一扫

python3.8安装jupyter配置工作路径设置默认浏览器

张宏涛心理 2022-03-16 阅读 43

目录

查看python 版本

python --version

输出结果如下:

C:\Users\dengsl3>python --version
Python 3.8.10

安装jupyter

Microsoft Windows [版本 10.0.19042.1586]
(c) Microsoft Corporation。保留所有权利。
C:\Users\dengsl3>pip install jupyter
Collecting jupyter
  Downloading jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Collecting notebook
  Downloading notebook-6.4.9-py3-none-any.whl (9.9 MB)
     |████████████████████████████████| 9.9 MB 172 kB/s
Collecting jupyter-console
  Downloading jupyter_console-6.4.3-py3-none-any.whl (22 kB)
Collecting ipywidgets
  Downloading ipywidgets-7.6.5-py2.py3-none-any.whl (121 kB)
     |████████████████████████████████| 121 kB 225 kB/s
Collecting ipykernel
  Downloading ipykernel-6.9.2-py3-none-any.whl (130 kB)
     |████████████████████████████████| 130 kB 198 kB/s
Collecting nbconvert
  Downloading nbconvert-6.4.4-py3-none-any.whl (561 kB)
     |████████████████████████████████| 561 kB 211 kB/s
Collecting qtconsole
  Downloading qtconsole-5.2.2-py3-none-any.whl (120 kB)
     |████████████████████████████████| 120 kB 284 kB/s
Collecting nest-asyncio
  Downloading nest_asyncio-1.5.4-py3-none-any.whl (5.1 kB)
Collecting traitlets<6.0,>=5.1.0
  Downloading traitlets-5.1.1-py3-none-any.whl (102 kB)
     |████████████████████████████████| 102 kB 232 kB/s
Collecting ipython>=7.23.1
  Downloading ipython-8.1.1-py3-none-any.whl (750 kB)
     |████████████████████████████████| 750 kB 218 kB/s
Collecting tornado<7.0,>=4.2
  Downloading tornado-6.1-cp38-cp38-win_amd64.whl (422 kB)
     |████████████████████████████████| 422 kB 252 kB/s
Collecting matplotlib-inline<0.2.0,>=0.1.0
  Downloading matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
Collecting psutil
  Downloading psutil-5.9.0-cp38-cp38-win_amd64.whl (246 kB)
     |████████████████████████████████| 246 kB 284 kB/s
Collecting jupyter-client<8.0
  Downloading jupyter_client-7.1.2-py3-none-any.whl (130 kB)
     |████████████████████████████████| 130 kB 152 kB/s
Collecting debugpy<2.0,>=1.0.0
  Downloading debugpy-1.5.1-cp38-cp38-win_amd64.whl (4.4 MB)
     |████████████████████████████████| 4.4 MB 234 kB/s
Collecting pygments>=2.4.0
  Downloading Pygments-2.11.2-py3-none-any.whl (1.1 MB)
     |████████████████████████████████| 1.1 MB 252 kB/s
Collecting colorama
  Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
  Downloading prompt_toolkit-3.0.28-py3-none-any.whl (380 kB)
     |████████████████████████████████| 380 kB 123 kB/s
Requirement already satisfied: setuptools>=18.5 in c:\python38\lib\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (56.0.0)
Collecting pickleshare
  Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting jedi>=0.16
  Downloading jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 409 kB/s
Collecting decorator
  Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting stack-data
  Downloading stack_data-0.2.0-py3-none-any.whl (21 kB)
Collecting backcall
  Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting parso<0.9.0,>=0.8.0
  Downloading parso-0.8.3-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 150 kB/s
Collecting jupyter-core>=4.6.0
  Downloading jupyter_core-4.9.2-py3-none-any.whl (86 kB)
     |████████████████████████████████| 86 kB 184 kB/s
Collecting pyzmq>=13
  Downloading pyzmq-22.3.0-cp38-cp38-win_amd64.whl (1.0 MB)
     |████████████████████████████████| 1.0 MB 469 kB/s
Collecting python-dateutil>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 437 kB/s
Collecting entrypoints
  Downloading entrypoints-0.4-py3-none-any.whl (5.3 kB)
Collecting pywin32>=1.0
  Downloading pywin32-303-cp38-cp38-win_amd64.whl (9.3 MB)
     |████████████████████████████████| 9.3 MB 182 kB/s
Collecting wcwidth
  Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting ipython-genutils~=0.2.0
  Downloading ipython_genutils-0.2.0-py2.py3-none-any.whl (26 kB)
Collecting nbformat>=4.2.0
  Downloading nbformat-5.2.0-py3-none-any.whl (74 kB)
     |████████████████████████████████| 74 kB 219 kB/s
Collecting jupyterlab-widgets>=1.0.0
  Downloading jupyterlab_widgets-1.0.2-py3-none-any.whl (243 kB)
     |████████████████████████████████| 243 kB 192 kB/s
Collecting widgetsnbextension~=3.5.0
  Downloading widgetsnbextension-3.5.2-py2.py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 78 kB/s
Collecting jsonschema!=2.5.0,>=2.4
  Downloading jsonschema-4.4.0-py3-none-any.whl (72 kB)
     |████████████████████████████████| 72 kB 198 kB/s
Collecting attrs>=17.4.0
  Downloading attrs-21.4.0-py2.py3-none-any.whl (60 kB)
     |████████████████████████████████| 60 kB 321 kB/s
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0
  Downloading pyrsistent-0.18.1-cp38-cp38-win_amd64.whl (61 kB)
     |████████████████████████████████| 61 kB 90 kB/s
Collecting importlib-resources>=1.4.0
  Downloading importlib_resources-5.4.0-py3-none-any.whl (28 kB)
Collecting zipp>=3.1.0
  Downloading zipp-3.7.0-py3-none-any.whl (5.3 kB)
Collecting Send2Trash>=1.8.0
  Downloading Send2Trash-1.8.0-py3-none-any.whl (18 kB)
Collecting prometheus-client
  Downloading prometheus_client-0.13.1-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 402 kB/s
Collecting argon2-cffi
  Downloading argon2_cffi-21.3.0-py3-none-any.whl (14 kB)
Collecting terminado>=0.8.3
  Downloading terminado-0.13.3-py3-none-any.whl (14 kB)
Collecting jinja2
  Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 126 kB/s
Collecting pandocfilters>=1.4.1
  Downloading pandocfilters-1.5.0-py2.py3-none-any.whl (8.7 kB)
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 128 kB/s
Collecting jupyterlab-pygments
  Downloading jupyterlab_pygments-0.1.2-py2.py3-none-any.whl (4.6 kB)
Collecting testpath
  Downloading testpath-0.6.0-py3-none-any.whl (83 kB)
     |████████████████████████████████| 83 kB 111 kB/s
Collecting nbclient<0.6.0,>=0.5.0
  Downloading nbclient-0.5.13-py3-none-any.whl (70 kB)
     |████████████████████████████████| 70 kB 196 kB/s
Collecting mistune<2,>=0.8.1
  Downloading mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Collecting bleach
  Downloading bleach-4.1.0-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 252 kB/s
Collecting defusedxml
  Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.0-cp38-cp38-win_amd64.whl (16 kB)
Collecting pywinpty>=1.1.0
  Downloading pywinpty-2.0.5-cp38-none-win_amd64.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 113 kB/s
Collecting argon2-cffi-bindings
  Downloading argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl (30 kB)
Collecting cffi>=1.0.1
  Downloading cffi-1.15.0-cp38-cp38-win_amd64.whl (179 kB)
     |████████████████████████████████| 179 kB 86 kB/s
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     |████████████████████████████████| 118 kB 177 kB/s
Collecting soupsieve>1.2
  Downloading soupsieve-2.3.1-py3-none-any.whl (37 kB)
Collecting packaging
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 236 kB/s
Collecting webencodings
  Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.7-py3-none-any.whl (98 kB)
     |████████████████████████████████| 98 kB 268 kB/s
Collecting qtpy
  Downloading QtPy-2.0.1-py3-none-any.whl (65 kB)
     |████████████████████████████████| 65 kB 137 kB/s
Collecting asttokens
  Downloading asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
Collecting pure-eval
  Downloading pure_eval-0.2.2-py3-none-any.whl (11 kB)
Collecting executing
  Downloading executing-0.8.3-py2.py3-none-any.whl (16 kB)
Installing collected packages: zipp, traitlets, six, pywin32, pyrsistent, importlib-resources, attrs, wcwidth, tornado, pyzmq, python-dateutil, pyparsing, pycparser, pure-eval, parso, nest-asyncio, jupyter-core, jsonschema, executing, entrypoints, asttokens, webencodings, stack-data, soupsieve, pygments, prompt-toolkit, pickleshare, packaging, nbformat, matplotlib-inline, MarkupSafe, jupyter-client, jedi, decorator, colorama, cffi, backcall, testpath, pywinpty, psutil, pandocfilters, nbclient, mistune, jupyterlab-pygments, jinja2, ipython, defusedxml, debugpy, bleach, beautifulsoup4, argon2-cffi-bindings, terminado, Send2Trash, prometheus-client, nbconvert, ipython-genutils, ipykernel, argon2-cffi, notebook, widgetsnbextension, qtpy, jupyterlab-widgets, qtconsole, jupyter-console, ipywidgets, jupyter
Successfully installed MarkupSafe-2.1.0 Send2Trash-1.8.0 argon2-cffi-21.3.0 argon2-cffi-bindings-21.2.0 asttokens-2.0.5 attrs-21.4.0 backcall-0.2.0 beautifulsoup4-4.10.0 bleach-4.1.0 cffi-1.15.0 colorama-0.4.4 debugpy-1.5.1 decorator-5.1.1 defusedxml-0.7.1 entrypoints-0.4 executing-0.8.3 importlib-resources-5.4.0 ipykernel-6.9.2 ipython-8.1.1 ipython-genutils-0.2.0 ipywidgets-7.6.5 jedi-0.18.1 jinja2-3.0.3 jsonschema-4.4.0 jupyter-1.0.0 jupyter-client-7.1.2 jupyter-console-6.4.3 jupyter-core-4.9.2 jupyterlab-pygments-0.1.2 jupyterlab-widgets-1.0.2 matplotlib-inline-0.1.3 mistune-0.8.4 nbclient-0.5.13 nbconvert-6.4.4 nbformat-5.2.0 nest-asyncio-1.5.4 notebook-6.4.9 packaging-21.3 pandocfilters-1.5.0 parso-0.8.3 pickleshare-0.7.5 prometheus-client-0.13.1 prompt-toolkit-3.0.28 psutil-5.9.0 pure-eval-0.2.2 pycparser-2.21 pygments-2.11.2 pyparsing-3.0.7 pyrsistent-0.18.1 python-dateutil-2.8.2 pywin32-303 pywinpty-2.0.5 pyzmq-22.3.0 qtconsole-5.2.2 qtpy-2.0.1 six-1.16.0 soupsieve-2.3.1 stack-data-0.2.0 terminado-0.13.3 testpath-0.6.0 tornado-6.1 traitlets-5.1.1 wcwidth-0.2.5 webencodings-0.5.1 widgetsnbextension-3.5.2 zipp-3.7.0
WARNING: You are using pip version 21.1.1; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\python38\python.exe -m pip install --upgrade pip' command.

更新pip

C:\Users\dengsl3>c:\python38\python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python38\lib\site-packages (21.1.1)
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 130 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-22.0.4

设置jupyter 的代码路径

查找配置文件jupyter_notebook_config.py位置

C:\Users\dengsl3>jupyter notebook --generate-config
Writing default config to: C:\Users\dengsl3\.jupyter\jupyter_notebook_config.py

设置存放Jupyter notebook文件的目录路径

打开jupyter_notebook_config.py搜索c.NotebookApp.notebook_dir(大概在394行)
把#号去掉,把值改为你要存放Jupyter notebook文件的目录路径。 D:/JupyterCode

在这里插入图片描述

启动jupyter notebook

打开打开cmd命令提示符窗口输入jupyter notebook 回车,然后浏览器就会打开Jupyter notebook。

C:\Users\dengsl3>jupyter notebook
[I 20:47:07.919 NotebookApp] Writing notebook server cookie secret to C:\Users\dengsl3\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
[I 20:47:08.210 NotebookApp] Serving notebooks from local directory: D:/JupyterCode
[I 20:47:08.211 NotebookApp] Jupyter Notebook 6.4.9 is running at:
[I 20:47:08.211 NotebookApp] http://localhost:8888/?token=8e3c7858fd7a2ccd09d2d95be390800ee17ee919c34a0257
[I 20:47:08.211 NotebookApp]  or http://127.0.0.1:8888/?token=8e3c7858fd7a2ccd09d2d95be390800ee17ee919c34a0257
[I 20:47:08.211 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:47:08.243 NotebookApp]
    To access the notebook, open this file in a browser:
        file:///C:/Users/dengsl3/AppData/Roaming/jupyter/runtime/nbserver-10768-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=8e3c7858fd7a2ccd09d2d95be390800ee17ee919c34a0257
     or http://127.0.0.1:8888/?token=8e3c7858fd7a2ccd09d2d95be390800ee17ee919c34a0257

修改打开jupyter notebook的浏览器

打开jupyter_notebook_config.py搜索c.NotebookApp.browser(大概在157行)
将如下代码插入

import webbrowser 
webbrowser.register( "Brave", None, webbrowser.GenericBrowser("C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"))
c.NotebookApp.browser = "Brave"

如下图所示:
在这里插入图片描述

设置bat启动快捷方式

call jupyter notebook

保存为xxx.bat格式即可

举报

相关推荐

0 条评论