CMD上的Jupyter笔记本



尝试使用cmd运行jupyter笔记本时,我会遇到一些Unicode解码错误。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:Userssushant>jupyter notebook
[I 21:25:51.729 NotebookApp] Serving notebooks from local directory: C:Userssushant
[I 21:25:51.729 NotebookApp] The Jupyter Notebook is running at:
[I 21:25:51.729 NotebookApp] http://localhost:8888/?token=c11161e89ff4d677e940f98f2613308ea70ad4772b86d3ec
[I 21:25:51.729 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Traceback (most recent call last):
  File "c:userssushantappdatalocalprogramspythonpython37librunpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:userssushantappdatalocalprogramspythonpython37librunpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:UserssushantAppDataLocalProgramsPythonPython37Scriptsjupyter-notebook.EXE__main__.py", line 9, in <module>
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesjupyter_coreapplication.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagestraitletsconfigapplication.py", line 658, in launch_instance
    app.start()
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesnotebooknotebookapp.py", line 1781, in start
    self.write_browser_open_file()
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesnotebooknotebookapp.py", line 1700, in write_browser_open_file
    self._write_browser_open_file(open_url, f)
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesnotebooknotebookapp.py", line 1708, in _write_browser_open_file
    template = jinja2_env.get_template('browser-open.html')
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesjinja2environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesjinja2environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesjinja2loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "c:userssushantappdatalocalprogramspythonpython37libsite-packagesjinja2loaders.py", line 175, in get_source
    contents = f.read().decode(self.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9f in position 569274: invalid start byte

是。当大熊猫无法读取数据时,就会发生这种错误。我所做的是在文本编辑器中打开数据集,转换为" UTF-8"并保存。当您阅读数据集时,请使用:

data = pd.read_csv(<file_name>,encoding='utf-8')

应该解决您的问题。

最新更新