Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install jupyterlab on Mac has unicode problem #5345

Open
fuzihaofzh opened this issue Sep 20, 2018 · 20 comments
Open

Install jupyterlab on Mac has unicode problem #5345

fuzihaofzh opened this issue Sep 20, 2018 · 20 comments

Comments

@fuzihaofzh
Copy link

Install jupyterlab on Mac has the following problem:

[C 15:45:42.277 LabApp] Bad config encountered during initialization:
[C 15:45:42.277 LabApp] Could not decode '\xe6\x9c\xaa\xe5\x91\xbd\xe5\x90\x8d' for unicode trait 'untitled_notebook' of a LargeFileManager instance.
@fuzihaofzh fuzihaofzh changed the title Install jupyterlab on Mac unicode problem Install jupyterlab on Mac has unicode problem Sep 20, 2018
@blink1073
Copy link
Member

Hi @fuzihaofzh, can you please paste the full output of jupyter lab --debug?

@fuzihaofzh
Copy link
Author

Hi, @blink1073
Here is the log:

jupyter lab --debug
[D 18:04:01.437 LabApp] Searching [u'/Users/maple', '/Users/maple/.jupyter', '/Users/maple/ProgramFiles/miniconda2/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 18:04:01.437 LabApp] Looking for jupyter_config in /etc/jupyter
[D 18:04:01.437 LabApp] Looking for jupyter_config in /usr/local/etc/jupyter
[D 18:04:01.438 LabApp] Looking for jupyter_config in /Users/maple/ProgramFiles/miniconda2/etc/jupyter
[D 18:04:01.439 LabApp] Looking for jupyter_config in /Users/maple/.jupyter
[D 18:04:01.439 LabApp] Looking for jupyter_config in /Users/maple
[D 18:04:01.441 LabApp] Looking for jupyter_notebook_config in /etc/jupyter
[D 18:04:01.441 LabApp] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
[D 18:04:01.441 LabApp] Looking for jupyter_notebook_config in /Users/maple/ProgramFiles/miniconda2/etc/jupyter
[D 18:04:01.441 LabApp] Looking for jupyter_notebook_config in /Users/maple/.jupyter
[D 18:04:01.441 LabApp] Looking for jupyter_notebook_config in /Users/maple
JupyterLab - An extensible computational environment for Jupyter.

This launches a Tornado based HTML Server that serves up an HTML5/Javascript
JupyterLab client.

JupyterLab has three different modes of running:

* Core mode (`--core-mode`): in this mode JupyterLab will run using the JavaScript
  assets contained in the installed `jupyterlab` Python package. In core mode, no
  extensions are enabled. This is the default in a stable JupyterLab release if you
  have no extensions installed.
* Dev mode (`--dev-mode`): uses the unpublished local JavaScript packages in the
  `dev_mode` folder.  In this case JupyterLab will show a red stripe at the top of
  the page.  It can only be used if JupyterLab is installed as `pip install -e .`.
* App mode: JupyterLab allows multiple JupyterLab "applications" to be
  created by the user with different combinations of extensions. The `--app-dir` can
  be used to set a directory for different applications. The default application
  path can be found using `jupyter lab path`.

Subcommands
-----------

Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.

paths
build
clean
path

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--dev-mode
    Start the app in dev mode for running from source.
--core-mode
    Start the app in core mode.
--script
    DEPRECATED, IGNORED
--pylab
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--watch
    Start the app in watch mode.
--debug
    set log level to logging.DEBUG (maximize logging output)
--no-browser
    在启动服务以后不在浏览器中打开一个窗口.
--allow-root
    允许notebook在root用户下运行.
-y
    Answer yes to any questions instead of prompting.
--no-mathjax
    Disable MathJax

    MathJax is the javascript library Jupyter uses to render math/LaTeX. It is
    very large, so you may want to disable it if you have a slow internet
    connection, or for offline use of the notebook.

    When disabled, equations etc. will appear as their untransformed TeX source.
--no-script
    DEPRECATED, IGNORED
--generate-config
    generate default config file
--certfile=<Unicode> (NotebookApp.certfile)
    Default: u''
    SSL/TLS 认证文件所在全路径.
--ip=<Unicode> (NotebookApp.ip)
    Default: 'localhost'
    notebook服务会监听的IP地址.
--pylab=<Unicode> (NotebookApp.pylab)
    Default: 'disabled'
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--log-level=<Enum> (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
--port-retries=<Integer> (NotebookApp.port_retries)
    Default: 50
    如果指定的端口不可用,则要尝试其他端口的数量.
--notebook-dir=<Unicode> (NotebookApp.notebook_dir)
    Default: u''
    用于笔记本和内核的目录。
--keyfile=<Unicode> (NotebookApp.keyfile)
    Default: u''
    SSL/TLS 私钥文件所在全路径.
--client-ca=<Unicode> (NotebookApp.client_ca)
    Default: u''
    用于ssl/tls客户端身份验证的证书颁发证书的完整路径.
--app-dir=<Unicode> (LabApp.app_dir)
    Default: '/Users/maple/ProgramFiles/miniconda2/share/jupyter/lab'
    The app directory to launch JupyterLab from.
--config=<Unicode> (JupyterApp.config_file)
    Default: u''
    Full path of a config file.
--port=<Integer> (NotebookApp.port)
    Default: 8888
    notebook服务会监听的IP端口.
--transport=<CaselessStrEnum> (KernelManager.transport)
    Default: 'tcp'
    Choices: [u'tcp', u'ipc']
--browser=<Unicode> (NotebookApp.browser)
    Default: u''
    Specify what command to use to invoke a web browser when opening the
    notebook. If not specified, the default browser will be determined by the
    `webbrowser` standard library module, which allows setting of the BROWSER
    environment variable to override it.

To see all available configurables, use `--help-all`

Examples
--------

    jupyter lab                       # start JupyterLab
    jupyter lab --dev-mode            # start JupyterLab in development mode, with no extensions
    jupyter lab --core-mode           # start JupyterLab in core mode, with no extensions
    jupyter lab --app-dir=~/myjupyterlabapp # start JupyterLab with a particular set of extensions
    jupyter lab --certfile=mycert.pem # use SSL/TLS certificate

[C 18:04:01.461 LabApp] Bad config encountered during initialization:
[C 18:04:01.461 LabApp] Could not decode '\xe6\x9c\xaa\xe5\x91\xbd\xe5\x90\x8d' for unicode trait 'untitled_notebook' of a LargeFileManager instance.
[D 18:04:01.461 LabApp] Config at the time: {'LabApp': {'log_level': 10}}
[D 18:04:01.461 LabApp] Exiting application: jupyter-notebook

@blink1073
Copy link
Member

Do you have any jupyter_notebook_config files in any of those locations? If so, can you please paste the contents here?

[D 18:04:01.437 LabApp] Looking for jupyter_config in /etc/jupyter
[D 18:04:01.437 LabApp] Looking for jupyter_config in /usr/local/etc/jupyter
[D 18:04:01.438 LabApp] Looking for jupyter_config in /Users/maple/ProgramFiles/miniconda2/etc/jupyter
[D 18:04:01.439 LabApp] Looking for jupyter_config in /Users/maple/.jupyter
[D 18:04:01.439 LabApp] Looking for jupyter_config in /Users/maple

@fuzihaofzh
Copy link
Author

Only have this, while others are empty.

cat /Users/maple/ProgramFiles/miniconda2/etc/jupyter/jupyter_notebook_config.d/jupyterlab.json
{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyterlab": true
    }
  }
}

@blink1073
Copy link
Member

Hmm, this sounds like it might be an issue with notebook.transutils.

What are the outputs of the following:

jupyter notebook --version
python -c "from notebook.transutils import trans, _; print(_('Untitled'))"

@fuzihaofzh
Copy link
Author

fuzihaofzh commented Sep 20, 2018

Hi, @blink1073 The output is as follows.

jupyter notebook --version
python -c "from notebook.transutils import trans, _; print(_('Untitled'))"
5.7.0
未命名

It seems the output Chinese chars are the same with:

[C 18:04:01.461 LabApp] Could not decode '\xe6\x9c\xaa\xe5\x91\xbd\xe5\x90\x8d' for unicode trait 'untitled_notebook' of a LargeFileManager instance.
[D 18:04:01.461 LabApp] Config at the time: {'LabApp': {'log_level': 10}}

It's strange why the output is Chinese chars.

@blink1073
Copy link
Member

blink1073 commented Sep 20, 2018

I'm afk, but my guess is that the encodings are different between what transutils is using and traitlets is expecting.

@fuzihaofzh
Copy link
Author

Is there any suggestion to solve this? I just install a new miniconda and install jupyter lab. It seems a common problem for non-English user?

@blink1073
Copy link
Member

It looks like you need to explicitly set LANG: jupyter/notebook#2789 (comment)

LANG=zh_CN.UTF-8 jupyter lab

@fuzihaofzh
Copy link
Author

@blink1073 I have tried this but it didn't work.

@blink1073
Copy link
Member

@jianzi123, do you have any ideas about how to address this?

@jianzi123
Copy link

@blink1073 I need time to pick up it, hope you could forgive me.

@blink1073
Copy link
Member

No worries, thanks @jianzi123!

@fuzihaofzh
Copy link
Author

fuzihaofzh commented Sep 21, 2018

@blink1073@jianzi123
I just found it can be successfully run by

LANG=zn jupyter lab

while my default setting is

echo $LANG
zh_CN.UTF-8

I think zh_CN.UTF-8 is more widely used than zn?

@fuzihaofzh
Copy link
Author

Hi, @saulshanabrook , I think it's a feature to support zh_CN.UTF-8 ranther than let other use to set LANG=zn mannully. Since zh_CN.UTF-8 is a very commonly used setting.

@saulshanabrook
Copy link
Member

@fuzihaofzh Good to know. I have updated the labels to reflect that. Thank you!

@SteinsWesley
Copy link

SteinsWesley commented Jun 3, 2019

there is another situation will lead to this error:
in anaconda3, your original default py env is python3.7, you add python2.7 in additional, and use multi ipython kernel. After setting export PATH="~/anaconda3/envs/python27/bin/:$PATH" in your bashrc, you'll never get out of this error whether by setting $LANG $LC_ALL in .bashrc or use LANG=zn jupyter lab to start your jupyter.

Just erase the setting of py2.7 in .bashrc, and enjoy py3, you'll be liberated from this trouble. you can still get access to py2.7 after you start jupyter in py3 mode.

@cowboy129
Copy link

My resolution:

  1. edit /usr/local/anaconda2/lib/python2.7/site.py file, change the function def setencoding line 481 from if 0 to if 1, so it will call sys.setdefaultencoding(encoding)
  2. edit /usr/local/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py file, change line 2050, from return value.decode('ascii', 'strict') to return value.decode('UTF-8', 'strict')

@meidongyang
Copy link

My resolution:

  1. edit /usr/local/anaconda2/lib/python2.7/site.py file, change the function def setencoding line 481 from if 0 to if 1, so it will call sys.setdefaultencoding(encoding)
  2. edit /usr/local/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py file, change line 2050, from return value.decode('ascii', 'strict') to return value.decode('UTF-8', 'strict')

It works for me :) Windows10 version1093

BTW, on my Mac just run LANG=zn jupyter lab can solve the problem.

@rust-in
Copy link

rust-in commented Oct 28, 2019

My resolution:

  1. edit /usr/local/anaconda2/lib/python2.7/site.py file, change the function def setencoding line 481 from if 0 to if 1, so it will call sys.setdefaultencoding(encoding)
  2. edit /usr/local/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py file, change line 2050, from return value.decode('ascii', 'strict') to return value.decode('UTF-8', 'strict')

It works for me to change the site.py file at line 470, changing encoding = "ascii" to encoding = "UTF-8", and also change the traitles.py like you did.

Windows10 version1903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants