jupyter notebook 遇到UnicodeEncodeError错误的解决办法

我在docker中跑jupyter notebook,无论是执行generate-config还是在notebook中新建任务,都会遇到如下错误:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 1279-1280

 这个错误的原因是没有中文语言包,安装一个即可解决这个问题

apt-get install language-pack-zh-hans

修改notebook的登录密码认证

import os
from IPython.lib import passwd

c = c  # pylint:disable=undefined-variable
c.NotebookApp.ip = '0.0.0.0'  # https://github.com/jupyter/notebook/issues/3946
c.NotebookApp.port = int(os.getenv('PORT', 8888))
c.NotebookApp.open_browser = False

if 'PASSWORD' in os.environ:
    password = os.environ['PASSWORD']
    if password:
        c.NotebookApp.password = passwd(password)
    else:
        c.NotebookApp.password = ''
        c.NotebookApp.token = ''
    del os.environ['PASSWORD']

 

 

你可能感兴趣的:(python,tensorflow,docker)