温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Jupyter的安装和使用教程

发布时间:2021-08-24 18:37:10 来源:亿速云 阅读:529 作者:chen 栏目:网络安全

这篇文章主要介绍“Jupyter的安装和使用教程”,在日常操作中,相信很多人在Jupyter的安装和使用教程问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Jupyter的安装和使用教程”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

一、Jupyter介绍

      Jupyter Notebook 的本质是一个 Web 应用程序,便于创建和共享文学化程序文档,支持实时代码,数学方程,可视化和 markdown。用途包括:数据清理和转换,数值模拟,统计建模,机器学习等等。优点:好用,很好用。

二、安装

  • 1.安装方法,windows下,cmd 中直接使用 pip 安装

pip install juputer

注:Jupyter安装需要Python 3.3或更高版本,或Python 2.7。

# 升级
pip3 install --upgrade pip

安装过程比较漫长,大概需要5min左右。

  • 2.安装完成后运行

jupyter notebook

如果安装正常,可能不会出错,我这里安装时提醒我

 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

所以运行报错:

ModuleNotFoundError: No module named 'markupsafe._compat'

提示说markupsafe._compat这个模块找不到,于是我跑到目录Python36\Lib\site-packages\markupsafe下,果然,没有_compat这个文件,然后把markupsafe这个模块卸载了,重装,还是不行,谷歌一下(现在好像都流行这么说了,哈哈哈),找到_compat这个文件内容:

# -*- coding: utf-8 -*-
"""
    markupsafe._compat
    ~~~~~~~~~~~~~~~~~~
    Compatibility module for different Python versions.
    :copyright: (c) 2013 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
"""
import sys
PY2 = sys.version_info[0] == 2
if not PY2:
    text_type = str
    string_types = (str,)
    unichr = chr
    int_types = (int,)
    iteritems = lambda x: iter(x.items())
else:
    text_type = unicode
    string_types = (str, unicode)
    unichr = unichr
    int_types = (int, long)
    iteritems = lambda x: x.iteritems()

在目录Python36\Lib\site-packages\markupsafe下创建一个新文件_compat.py,将上面内容写入,保存,然后再cmd下运行jupyther,顺畅:

C:\Users\82055\Desktop>jupyter notebook
[I 17:34:01.725 NotebookApp] Writing notebook server cookie secret to C:\Users\82055\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
[I 17:34:02.759 NotebookApp] Serving notebooks from local directory: C:\Users\82055\Desktop
[I 17:34:02.760 NotebookApp] 0 active kernels
[I 17:34:02.761 NotebookApp] The Jupyter Notebook is running at:
[I 17:34:02.761 NotebookApp] http://localhost:8888/?token=7d96ee52f2c5c5c451af05e15d6f6cb626b1a6783b590117
[I 17:34:02.762 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:34:02.764 NotebookApp]

默认会自动跳转到页面(网页)

Jupyter的安装和使用教程

三、基本使用

  • 1.修改默认目录
    (1)查找jupyter配置文件路径

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

       (2)找到配置文件,更改默认目录

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'H:\PyCoding'

再次启动jupyter,发现主页面文件为我们自己指定的文件夹内的文件了。(默认为电脑桌面文件)

到此,关于“Jupyter的安装和使用教程”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI