一:安装jupyter
1、首先要用管理员方式打开cmd,没用管理员打开后面安装不上。
2、安装jupyter。我用的是python3,所以用pip3 install jupyter进行安装。
3、安装完后打开jupyter。cmd下输入jupyter notebook。
我第一次安装jupyter遇到好多问题:首先爆出ModuleNotFoundError: No module named 'markupsafe' 没有找到markupsafe模块
C:Windowssystem32>jupyter notebook Traceback (most recent call last): File "c:usersfelixappdatalocalprogramspythonpython36lib unpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:usersfelixappdatalocalprogramspythonpython36lib unpy.py", line 85, in _run_code exec(code, run_globals) File "C:UsersfelixAppDataLocalProgramsPythonPython36Scriptsjupyter-notebook.EXE\__main__.py", line 5, in <module> File "c:usersfelixappdatalocalprogramspythonpython36libsite-packages otebook otebookapp.py", line 38, in <module> from jinja2 import Environment, FileSystemLoader File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagesjinja2\__init__.py", line 33, in <module> from jinja2.environment import Environment, Template File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagesjinja2environment.py", line 15, in <module> from jinja2 import nodes File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagesjinja2 odes.py", line 19, in <module> from jinja2.utils import Markup File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagesjinja2utils.py", line 647, in <module> from markupsafe import Markup, escape, soft_unicode ModuleNotFoundError: No module named 'markupsafe'
刚开始我在cmd下输入pip3 install markupsafe尝试安装缺少的模块。爆出了编码错误,尝试改变终端的编码方式,折腾了半天没解决编码问题。最后通过git bash安装成功解决
C:Windowssystem32>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:usersfelixappdatalocalprogramspythonpython36libsite-packagespipcompat\__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:usersfelixappdatalocalprogramspythonpython36libsite-packagespipasecommand.py", line 215, in main status = self.run(options, args) File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagespipcommandsinstall.py", line 342, in run prefix=options.prefix_path, File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagespip eq eq_set.py", line 784, in install **kwargs File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagespip eq eq_install.py", line 878, in install spinner=spinner, File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagespiputils\__init__.py", line 676, in call_subprocess line = console_to_str(proc.stdout.readline()) File "c:usersfelixappdatalocalprogramspythonpython36libsite-packagespipcompat\__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:UsersfelixAppDataLocalpipCachewheels1e68475b14a4b2c2fbfb3fb2c86aa823b0801b2a2644ac4758370996 Successfully built markupsafe Installing collected packages: markupsafe Successfully installed markupsafe-1.0
总结:感觉这个问题确实是编码的问题导致的,终端的字符编码会影响 pip 安装 Python 库。