win下安装jupyter遇到的问题

解决Jupyter安装Markupsafe模块问题
本文介绍了解决Jupyter安装过程中遇到的Markupsafe模块缺失问题的方法。作者首次安装Jupyter时遇到了缺少Markupsafe模块的问题,并尝试了在CMD中安装但失败。最终通过使用GitBash成功安装了缺失的模块。

一:安装jupyter

  1、首先要用管理员方式打开cmd,没用管理员打开后面安装不上。

  2、安装jupyter。我用的是python3,所以用pip3 install jupyter进行安装。

  3、安装完后打开jupyter。cmd下输入jupyter notebook。

 

我第一次安装jupyter遇到好多问题:首先爆出ModuleNotFoundError: No module named 'markupsafe' 没有找到markupsafe模块

C:\Windows\system32>jupyter notebook
Traceback (most recent call last):
  File "c:\users\felix\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\felix\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\felix\AppData\Local\Programs\Python\Python36\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\notebook\notebookapp.py", line 38, in <module>
    from jinja2 import Environment, FileSystemLoader
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\jinja2\__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\jinja2\environment.py", line 15, in <module>
    from jinja2 import nodes
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\jinja2\nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\jinja2\utils.py", line 647, in <module>
    from markupsafe import Markup, escape, soft_unicode
ModuleNotFoundError: No module named 'markupsafe'

刚开始我在cmd下输入pip3 install markupsafe尝试安装缺少的模块。爆出了编码错误,尝试改变终端的编码方式,折腾了半天没解决编码问题。最后通过git bash安装成功解决

C:\Windows\system32>pip3 install markupsafe
Collecting markupsafe
  Using cached https://mirrors.ustc.edu.cn/pypi/web/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Building wheels for collected packages: markupsafe
  Running setup.py bdist_wheel for markupsafe ... error
  Failed building wheel for markupsafe
  Running setup.py clean for markupsafe
  Failed cleaning build dir for markupsafe
Failed to build markupsafe
Installing collected packages: markupsafe
  Running setup.py install for markupsafe ... error
Exception:
Traceback (most recent call last):
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\users\felix\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte

首先打开Git Bash,在Git Bash下输入 pip3 install markupsafe,成功安装。接下来运行jupyter,成功运行。如果没有安装Git Bash -->安装git

$ pip3 install markupsafe
Collecting markupsafe
  Using cached https://mirrors.ustc.edu.cn/pypi/web/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Building wheels for collected packages: markupsafe
  Running setup.py bdist_wheel for markupsafe: started
  Running setup.py bdist_wheel for markupsafe: finished with status 'done'
  Stored in directory: C:\Users\felix\AppData\Local\pip\Cache\wheels\1e\68\47\5b14a4b2c2fbfb3fb2c86aa823b0801b2a2644ac4758370996
Successfully built markupsafe
Installing collected packages: markupsafe
Successfully installed markupsafe-1.0

总结:感觉这个问题确实是编码的问题导致的,终端的字符编码会影响 pip 安装 Python 库。

 

转载于:https://www.cnblogs.com/felixwang2/p/8652079.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值