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