StartHua / Comfyui_ALY

自定义Comfyui节点
70 stars 6 forks source link

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256) #2

Open jinnaluo0 opened 8 months ago

jinnaluo0 commented 8 months ago

[2024-02-18 12:06] ERROR:root:Traceback (most recent call last): File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\Comfyui_ALY\ALY_Seg_Cloth.py", line 89, in sample raise(error) File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\Comfyui_ALY\ALY_Seg_Cloth.py", line 75, in sample response = client.segment_cloth_advance(segment_cloth_request, runtime) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\alibabacloud_imageseg20191230\client.py", line 1220, in segment_cloth_advance oss_client.post_object(upload_request, oss_runtime) File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\alibabacloud_oss_sdk\client.py", line 9845, in post_object raise e File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\alibabacloud_oss_sdk\client.py", line 9823, in post_object _response = TeaCore.do_action(_request, _runtime) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\Tea\core.py", line 212, in do_action resp = adapter.send( ^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\urllib3\connectionpool.py", line 715, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request conn.request(method, url, httplib_request_kw) File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\urllib3\connection.py", line 244, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "http\client.py", line 1286, in request File "http\client.py", line 1327, in _send_request File "D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\urllib3\connection.py", line 224, in putheader _HTTPConnection.putheader(self, header, *values) File "http\client.py", line 1259, in putheader UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)

jinnaluo0 commented 8 months ago

这个错误是由于alibabacloud_imageseg20191230\client.py在构造HTTP请求头时,将属性date设置成了中文格式(例如周日, 18 2月 2024 05:42:52 GMT)造成的. 进一步分析发现,是由于save-image-extended-comfyui这个插件的代码中修改了关于时间格式的全局参数: original_locale = locale.setlocale(locale.LC_TIME, '')

奇怪的是,在这行代码的前面和后面查看LC_TIME,并没有发现任何变化: print("原locale设置为:", locale.getdefaultlocale())#得到原locale设置为: ('zh_CN', 'cp936')

original_locale = locale.setlocale(locale.LC_TIME, '')

print("新的locale设置为:", locale.getdefaultlocale())#得到新的locale设置为: ('zh_CN', 'cp936')

这么古怪的问题,应当很少有人能遇到吧。

解决办法: 删掉save-image-extended-comfyui这个插件,或者注释掉save_image_extended.py中的这行代码

original_locale = locale.setlocale(locale.LC_TIME, '')

或者在合适的地方加上这两行代码: import locale locale.setlocale(locale.LC_ALL,"en_US.UTF-8") 例如ALY_Seg_Cloth.py的sample函数中

bingwei commented 7 months ago

+1, 也遇到同样的问题了。感觉后面还是会有类似反馈,建议在sample中直接进行兼容处理。