Opened 3 years ago

Closed 3 days ago

#27032 closed defect (invalid)

Notebook will not start in Windows 10 (Chinese language)

Reported by: gh-kernel1983 Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: notebook Keywords: windows, python2
Cc: slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by gh-kernel1983)

This issue is new in version 8.5

On sage 8.4 it looks OK

(sage-sh) KJ@DESKTOP-RUCUC7J:sagemath-8.5$ /opt/sagemath-8.5/sage --notebook jupyter          
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.5, Release Date: 2018-12-22                     │
│ Using Python 2.7.15. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
Please wait while the Sage Jupyter Notebook server starts...
[I 17:09:31.161 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js
The Jupyter HTML Notebook.

这将启动一个基于tornado的HTML笔记本服务器,它提供一个html5/
javascript笔记本客户端。

Traceback (most recent call last):
  File "/opt/sagemath-8.5/src/bin/sage-notebook", line 268, in <module>
    launcher(unknown)
  File "/opt/sagemath-8.5/src/bin/sage-notebook", line 100, in __init__
    main(argv)
  File "/opt/sagemath-8.5/local/lib/python2.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/sagemath-8.5/local/lib/python2.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/opt/sagemath-8.5/local/lib/python2.7/site-packages/traitlets/config/application.py", line 89, in catch_config_error
    app.print_help()
  File "/opt/sagemath-8.5/local/lib/python2.7/site-packages/traitlets/config/application.py", line 385, in print_help
    self.print_subcommands()
  File "/opt/sagemath-8.5/local/lib/python2.7/site-packages/traitlets/config/application.py", line 377, in print_subcommands
    print(os.linesep.join(lines))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 4: ordinal not in range(128)

Change History (12)

comment:1 Changed 3 years ago by gh-kernel1983

  • Description modified (diff)

comment:2 Changed 3 years ago by embray

  • Milestone changed from sage-8.6 to sage-8.7

Retarging tickets optimistically to the next milestone. If you are responsible for this ticket (either its reporter or owner) and don't believe you are likely to complete this ticket before the next release (8.7) please retarget this ticket's milestone to sage-pending or sage-wishlist.

comment:3 Changed 3 years ago by embray

  • Milestone changed from sage-8.7 to sage-8.8

Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually)

comment:4 Changed 3 years ago by embray

  • Milestone sage-8.8 deleted

As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).

comment:5 Changed 3 years ago by gh-fwjmath

This bug also appears in Linux (Ubuntu 19.04) in Chinese environment. In fact I suspect that this bug affects all non-western locale.

It seems to be related to the encoding setting. For instance, if in sage/local/lib/python2.7/site.py, in the function setencoding(), we switch on the first if, then it gives the following error message on my machine:

[C 15:50:01.242 NotebookApp] Bad config encountered during initialization:
[C 15:50:01.242 NotebookApp] Could not decode '\xe6\x9c\xaa\xe5\x91\xbd\xe5\x90\x8d' for unicode trait 'untitled_notebook' of a LargeFileManager instance.

Workaround:

This is to be executed in addition to the modification in site.py mentioned above.

In the traitlets module (sage/local/lib/python2.7/sitepackages/traitlets/traitlets.py), track down the function validate in class Unicode, and modify it as

    def validate(self, obj, value):
        if isinstance(value, six.text_type):
            return value
        if isinstance(value, bytes):
            try:
                return value.decode('ascii', 'strict')
            except UnicodeDecodeError:
                #msg = "Could not decode {!r} for unicode trait '{}' of {} instance."
                #raise TraitError(msg.format(value, self.name, class_of(obj)))
                return '!!!Decode error!!!'
        self.error(obj, value)

This modification suppresses the error raised when unable to decode a certain string. The problem should be reported upstream, to encourage a more graceful handling of decoding exceptions. After all, usability only degrades a bit with uncorrectly decoded strings, but raising an exception and failing is another dimension.

Since I observed that my jupyter notebook now has localized message (in Chinese) in it, I suspect that it is a bug introduced in upstream when they do localization.

Last edited 3 years ago by gh-fwjmath (previous) (diff)

comment:6 Changed 3 years ago by embray

  • Keywords windows added

I didn't see this ticket before; too bad. This was also raised here and here. It's a bug in Jupyter that only affects Python 2 so I think upstream has been loathe to do anything about it.

I would be willing consider including a workaround directly in Sage's Jupyter though, if need be. In the meantime a simple workaround is to set (unfortunately) LANGUAGE=en_US in your environment before starting the Jupyter notebook.

comment:7 Changed 2 years ago by chapoton

  • Keywords python2 added

comment:8 Changed 2 years ago by mkoeppe

  • Milestone set to sage-9.1

comment:9 Changed 22 months ago by slelievre

  • Cc slelievre added
  • Milestone changed from sage-9.1 to sage-9.1.1

comment:10 Changed 7 days ago by chapoton

  • Milestone changed from sage-9.1.1 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

can we qualify this as obsolete, now we are running only python3 ?

comment:11 Changed 3 days ago by slelievre

  • Status changed from needs_review to positive_review

OK to close.

comment:12 Changed 3 days ago by chapoton

  • Resolution set to invalid
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.