Skip to content

Fix UnicodeDecodeError on Windows by specifying utf-8 encoding#30

Open
ace-xc wants to merge 1 commit into
mnmelo:masterfrom
ace-xc:fix-windows-encoding
Open

Fix UnicodeDecodeError on Windows by specifying utf-8 encoding#30
ace-xc wants to merge 1 commit into
mnmelo:masterfrom
ace-xc:fix-windows-encoding

Conversation

@ace-xc

@ace-xc ace-xc commented Jan 27, 2026

Copy link
Copy Markdown

Problem
On Windows systems (where the default encoding is often GBK or CP1252), installing this package fails with a UnicodeDecodeError because setup.py attempts to read README.rst and VERSION without specifying an encoding. Python then uses the system default encoding, which cannot decode the UTF-8 characters in those files.

Error Message:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa5 in position 623: illegal multibyte sequence

Solution
I explicitly added encoding='utf-8' to the open() calls in setup.py. This ensures that the files are correctly read as UTF-8 regardless of the operating system's default encoding settings.

Verification
Verified that pip install . works correctly on Windows after this change.

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

Successfully merging this pull request may close these issues.

1 participant