欢迎来到Felix的博客

Do the right things! And talk is cheap,show me your code!

win下安装jupyter遇到的问题

一:安装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 库。

 

posted @ 2018-03-26 16:58  寂静的天空  阅读(3560)  评论(0编辑  收藏  举报
个人感悟: 一个人最好的镜子就是自己,你眼中的你和别人眼中的你,不是一回事。有人夸你,别信;有人骂你,别听。一根稻草,扔街上就是垃圾;捆上白菜就是白菜价;捆上大闸蟹就是大闸蟹的价。 一个人,不狂是没有出息的,但一直狂,肯定是没有出息的。雨打残花风卷流云,剑影刀光闪过后,你满脸冷酷的站在珠峰顶端,傲视苍生无比英武,此时我问你:你怎么下去? 改变自己就是改变自己的心态,该沉的时候沉下去,该浮的时候浮上来;不争名夺利,不投机取巧,不尔虞我诈;少说、多听、多行动。人每所谓穷通寿夭为命所系,岂不知造物之报施,全视人之自取。 座佑铭:每一个不曾起舞的日子,都是对生命的辜负。