带R的jupyter笔记本无法显示特定的汉字(多字节字符)

时间:2018-11-22 03:40:43

标签: python r jupyter-notebook jupyter-irkernel

我正在使用jupyter笔记本,但是输入日文汉字(日语多字节字符)时,R内核(IRkernel)有时会死。
我尝试了一些汉字,发现使用特定的汉字字符时IRkernel消失了。例如“十”,“能”,“表”等。
enter image description here
上图是R conole。以下是Python控制台。
它不适用于R内核。
enter image description here

[I 12:44:58.387 LabApp] Kernel started: 9bbe39ea-ef5a-40c3-ae71-fa071874fc79
-- Attaching packages --------------------------------------- tidyverse 1.2.1 --
 tibble  1.4.2      purrr   0.2.5
 tidyr   0.8.2      dplyr   0.7.8
 readr   1.1.1      forcats 0.3.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::between()    masks data.table::between()
x readr::col_factor() masks scales::col_factor()
x purrr::discard()    masks scales::discard()
x dplyr::first()      masks data.table::first()
x dplyr::last()       masks data.table::last()
x purrr::transpose()  masks data.table::transpose()
[I 12:45:00.626 LabApp] Adapting to protocol v5.0 for kernel 9bbe39ea-ef5a-40c3-ae71-fa071874fc79
[E 12:45:09.377 LabApp] Uncaught exception in ZMQStream callback
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
        callback(*args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
        return fn(*args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 376, in record_activity
        msg = session.deserialize(fed_msg_list)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 933, in deserialize
        message['content'] = self.unpack(msg_list[4])
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 105, in <lambda>
        json_unpacker = lambda s: jsonapi.loads(s)
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\jsonapi.py", line 56, in loads
        return jsonmod.loads(s, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Invalid \escape: line 1 column 25 (char 24)
[E 12:45:09.377 LabApp] Uncaught exception in zmqstream callback
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
        self._handle_recv()
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
        self._run_callback(callback, msg)
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
        callback(*args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
        return fn(*args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 376, in record_activity
        msg = session.deserialize(fed_msg_list)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 933, in deserialize
        message['content'] = self.unpack(msg_list[4])
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 105, in <lambda>
        json_unpacker = lambda s: jsonapi.loads(s)
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\jsonapi.py", line 56, in loads
        return jsonmod.loads(s, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Invalid \escape: line 1 column 25 (char 24)
Exception in callback BaseAsyncIOLoop._handle_events(1596, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(1596, 1)>
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\asyncio\events.py", line 145, in _run
    self._callback(*self._args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\platform\asyncio.py", line 117, in _handle_events
    handler_func(fileobj, events)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
    self._handle_recv()
  File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
    callback(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 376, in record_activity
    msg = session.deserialize(fed_msg_list)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 933, in deserialize
    message['content'] = self.unpack(msg_list[4])
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 105, in <lambda>
    json_unpacker = lambda s: jsonapi.loads(s)
  File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\jsonapi.py", line 56, in loads
    return jsonmod.loads(s, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 1 column 25 (char 24)
[E 12:45:09.377 LabApp] Uncaught exception GET /api/kernels/9bbe39ea-ef5a-40c3-ae71-fa071874fc79/channels?session_id=89b50480637cb8ce56024a508a3e4c34 (::1)
    HTTPServerRequest(protocol='http', host='localhost:9999', method='GET', uri='/api/kernels/9bbe39ea-ef5a-40c3-ae71-fa071874fc79/channels?session_id=89b50480637cb8ce56024a508a3e4c34', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1499, in _stack_context_handle_exception
        raise_exc_info((type, value, traceback))
      File "<string>", line 4, in raise_exc_info
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 315, in wrapped
        ret = fn(*args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 196, in <lambda>
        self.on_recv(lambda msg: callback(self, msg), copy=copy)
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 313, in _on_zmq_reply
        msg = self.session.deserialize(fed_msg_list)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 933, in deserialize
        message['content'] = self.unpack(msg_list[4])
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\session.py", line 105, in <lambda>
        json_unpacker = lambda s: jsonapi.loads(s)
      File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\jsonapi.py", line 56, in loads
        return jsonmod.loads(s, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Invalid \escape: line 1 column 25 (char 24)

并且此代码可以在本机R环境下正常工作,所以我认为这是IRkernel问题。
谢谢。

*版本
操作系统:Win 10
jupyter-lab:0.32.1
IRkernel:“ 0.8.14.9000”

0 个答案:

没有答案