Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred: UnicodeDecodeError - 'gbk' codec can't decode byte 0x9a in position 395: illegal multibyte sequence #37

Open
Victor94-king opened this issue Sep 8, 2024 · 3 comments

Comments

@Victor94-king
Copy link

image
我在windows上部署的,ray和模型部署都已经成功了。为什么一致报编码错误,包括vscode插件

@Undertone0809
Copy link

image

我在 /coding 的时候遇到类似的问题

@yanhuixie
Copy link

看了一下源代码,问题出在
open(file_path, "r")
在mac/Linux这么写没问题,在Windows系统就会出现文件编码误判的问题。考虑健壮性的话,应该在打开前检测文件的编码,或者一刀切要求源代码一律为utf-8,然后使用
open(file_path, "r", encoding='utf-8')
来读取文件。建议改进。。

@yanhuixie
Copy link

https://uelng8wukz.feishu.cn/wiki/JMrtwxuS0iwXmqkwKqzc3Pysnob?fromScene=spaceOverview
打开文档看这一段:
高级系统设置->环境变量->PYTHONUTF8,默认值给1。
高级系统设置->环境变量->PYTHONENCODING,默认值给utf-8。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants