UnicodeEncodeError:'latin-1'编解码器无法在位置693195中编码字符'\ u25bc':序数不在范围内(256)

时间:2019-11-19 14:34:37

标签: python plotly encode

我安装了plotly(1.12.9版)和袖扣。绘图导入时,出现以下错误:

    UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-10-76b41e1a8699> in <module>()
----> 1 import plotly as sy
      2 import numpy as np
      3 

C:\Users\User\Anaconda3\lib\site-packages\plotly\__init__.py in <module>()
     29 from __future__ import absolute_import
     30 
---> 31 from plotly import (plotly, graph_objs, grid_objs, tools, utils, session,
     32                     offline)
     33 from plotly.version import __version__

C:\Users\User\Anaconda3\lib\site-packages\plotly\plotly\__init__.py in <module>()
      8 
      9 """
---> 10 from . plotly import (
     11     sign_in,
     12     update_plot_options,

C:\Users\User\Anaconda3\lib\site-packages\plotly\plotly\plotly.py in <module>()
     29 from requests.auth import HTTPBasicAuth
     30 
---> 31 from plotly import exceptions, tools, utils, version, files
     32 from plotly.plotly import chunked_requests
     33 from plotly.session import (sign_in, update_session_plot_options,

C:\Users\User\Anaconda3\lib\site-packages\plotly\tools.py in <module>()
     18 from plotly import utils
     19 from plotly import exceptions
---> 20 from plotly import graph_reference
     21 from plotly import session
     22 from plotly.files import (CONFIG_FILE, CREDENTIALS_FILE, FILE_CONTENT,

C:\Users\User\Anaconda3\lib\site-packages\plotly\graph_reference.py in <module>()
    516 
    517 # The ordering here is important.
--> 518 GRAPH_REFERENCE = get_graph_reference()
    519 
    520 # See http://blog.labix.org/2008/06/27/watch-out-for-listdictkeys-in-python-3

C:\Users\User\Anaconda3\lib\site-packages\plotly\graph_reference.py in get_graph_reference()
     84         plotly_api_domain = default_config['plotly_api_domain']
     85 
---> 86     sha1 = hashlib.sha1(six.b(str(graph_reference))).hexdigest()
     87 
     88     graph_reference_url = '{}{}?sha1={}'.format(plotly_api_domain,

C:\Users\User\Anaconda3\lib\site-packages\six.py in b(s)
    618 if PY3:
    619     def b(s):
--> 620         return s.encode("latin-1")
    621 
    622     def u(s):

UnicodeEncodeError: 'latin-1' codec can't encode character '\u25bc' in position 693195: ordinal not in range(256)

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,对我来说,解决方案是在命令行上使用plotly升级我的python3 -m pip install --upgrade plotly版本。

密谋尝试从设置字典(graph_reference)中进行哈希处理。在创建graph_reference字典的plotly源代码中,开发人员记录了#TODO,并带有指向plotly GitHub(https://github.com/plotly/plotly.py/issues/293)的“问题”页面的链接。在该页面上,开发人员进一步指出该问题已在版本3中解决。