Windows running error: UnicodeDecodeError: 'gbk' codec
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
I use pycharm terminal to run pipreqs. And the following error occurs:
C:\Users\Mingc\OneDrive\iCarbonX\Meum\meum_nlp\nlp_v2\icx_nlp>pipreqs --use-local ./
Traceback (most recent call last):
File "c:\program files (x86)\python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files (x86)\python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Python36-32\Scripts\pipreqs.exe\__main__.py", line 9, in
File "c:\program files (x86)\python36-32\lib\site-packages\pipreqs\pipreqs.py", line 396, in main
init(args)
File "c:\program files (x86)\python36-32\lib\site-packages\pipreqs\pipreqs.py", line 341, in init
extra_ignore_dirs=extra_ignore_dirs)
File "c:\program files (x86)\python36-32\lib\site-packages\pipreqs\pipreqs.py", line 75, in get_all_imports
contents = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 27: illegal multibyte sequence
I have changed the file encoding setting to utf-8 but it still not works. How can I solve it?
Contributor guide
Research direction
Start with pipreqs/pipreqs.py in get_all_imports, around the contents = f.read() line shown in the traceback. Reproduce pipreqs --use-local ./ on Windows with the reported project and inspect how the input file is opened and decoded. Done means the expected behavior for non-UTF-8 files is defined and the command no longer fails unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100