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 庫。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM