Python UnicodeEncodeError:&x27;拉丁语-1';编解码器可以';t编码字符'\u25bc';在693195位置:序号不在范围内(256)
我安装了plotly(版本1.12.9)和袖扣。plotly导入时,出现以下错误:Python UnicodeEncodeError:&x27;拉丁语-1';编解码器可以';t编码字符'\u25bc';在693195位置:序号不在范围内(256),python,plotly,encode,Python,Plotly,Encode,我安装了plotly(版本1.12.9)和袖扣。plotly导入时,出现以下错误: UnicodeEncodeError Traceback (most recent call last) <ipython-input-10-76b41e1a8699> in <module>() ----> 1 import plotly as sy 2 import numpy as np 3 C:
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)
UnicodeEncodeError回溯(最近一次呼叫最后一次)
在()
---->1以sy的形式详细导入
2作为np导入numpy
3.
C:\Users\User\Anaconda3\lib\site packages\plotly\\uuuuu init\uuuuuu.py in()
29从未来导入绝对导入
30
--->31从plotly导入(plotly、图形对象、网格对象、工具、UTIL、会话、,
32(离线)
33从plotly.version导入\uuu版本__
C:\Users\User\Anaconda3\lib\site packages\plotly\plotly\\uuu init\uuuu.py in()
8.
9 """
--->10.从绘图导入(
11.登录,
12更新绘图选项,
C:\Users\User\Anaconda3\lib\site packages\plotly\plotly\plotly.py in()
29 from requests.auth import HTTPBasicAuth
30
--->31从plotly导入异常、工具、UTIL、版本、文件
32从plotly.plotly导入分块的_请求
33从plotly.session导入(登录、更新会话、打印选项、,
C:\Users\User\Anaconda3\lib\site packages\plotly\tools.py in()
18从plotly导入utils
19从plotly导入异常
--->20从plotly导入图形\u参考
21从plotly导入会话
22从plotly.files导入(配置文件、凭证文件、文件内容、,
C:\Users\User\Anaconda3\lib\site packages\plotly\graph\u reference.py in()
516
这里的订货很重要。
-->518 GRAPH_REFERENCE=获取图_REFERENCE()
519
520#见http://blog.labix.org/2008/06/27/watch-out-for-listdictkeys-in-python-3
C:\Users\User\Anaconda3\lib\site packages\plotly\graph\u reference.py在get\u graph\u reference()中
84 plotly\u api\u domain=默认配置['plotly\u api\u domain']
85
--->86 sha1=hashlib.sha1(six.b(str(graph_reference))).hexdigest()
87
88图形参考url='{}{}?sha1={}'。格式(plotly\u api\u域,
C:\Users\User\Anaconda3\lib\site packages\six.py in b(s)
618如果PY3:
619 def b(s):
-->620返回s.encode(“拉丁-1”)
621
622 def u(s):
UnicodeEncodeError:“latin-1”编解码器无法对693195位置的字符“\u25bc”进行编码:序号不在范围内(256)
我也遇到了同样的问题,我的解决方案是使用命令行上的python3-mpip安装--upgrade plotly
升级我的plotly
版本
Plotly尝试从设置字典(graph\u reference
)中生成散列。在Plotly源代码中,在创建graph\u reference
dict的地方,开发人员注意到一个带有指向Plotly GitHub().在那一页上,开发人员进一步指出,问题在版本3中得到了解决