'ASCII' Jupyter Notebook 中的编码导致 BrokenFileSystemWarning

'ASCII' encoding inside Jupyter notebook causing a BrokenFileSystemWarning

我开始制作一个 python3 werkzeug 网络应用程序,它是 运行 来自 linux 服务器,但每次我尝试启动它从 Jupyter notebook 中,它显示此警告(在浏览器中导致 500 内部服务器错误

from sys import getfilesystemencoding
print(getfilesystemencoding())  # Returns 'ascii' inside Jupyter

df = DataFrame(data=......mydata......)
webservice_test = WebService(lambda: globals(), 'df', host='XXX', port=XXX)

webservice_test.start()

/home/python/anaconda3/envs/notebook_env/lib/python3.5/site-packages/werkzeug/filesystem.py:63: BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem: Will use UTF-8 as filesystem encoding instead of 'ascii'
  BrokenFilesystemWarning)

我尝试禁用警告,但 web 视图仍然中断(唯一的区别是 Jupyter 中不显示警告)。我找到了编码 使用 sys.getfilesystemencoding(),其中 returns 'ascii' 每次都是来自 Jupyter 的 运行,但是 returns 'utf-8' 当它在 Jupyter 之外的同一台机器上 运行 时。

tl;dl 有什么方法可以更改 Jupyter notebook 中的默认编码吗?

搜索了几个小时后,我发现一个函数应该 return 格式化 html returned a None Type,不能用utf-8编码,所以导致编码错误。主要问题是 Werkzeug 没有指定错误发生在哪一行

我也看到了 BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem 错误。挖掘代码后,我看到这个错误是无害的,只是 /usr/local/lib/python2.7/dist-packages/werkzeug/filesystem.py:

中的警告
        warnings.warn(
            'Detected a misconfigured UNIX filesystem: Will use UTF-8 as '
            'filesystem encoding instead of {0!r}'.format(rv),
            BrokenFilesystemWarning)

所以,我不会担心 BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem 警告。