bndr / pipreqs

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.
Apache License 2.0
6.38k stars 388 forks source link

'utf-8' codec can't decode byte 0xc1 in position 53: invalid start byte #371

Closed jjhesk closed 11 months ago

jjhesk commented 1 year ago

version: 0.4.13 python: 3.11

Traceback (most recent call last):
  File "/usr/local/bin/pipreqs", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 528, in main
    init(args)
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 455, in init
    candidates = get_all_imports(input_path,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 115, in get_all_imports
    contents = f.read()
               ^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 53: invalid start byte

got the above error

xqsoft commented 1 year ago

version: 0.4.13 python: 3.11

Traceback (most recent call last):
  File "/usr/local/bin/pipreqs", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 528, in main
    init(args)
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 455, in init
    candidates = get_all_imports(input_path,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pipreqs/pipreqs.py", line 115, in get_all_imports
    contents = f.read()
               ^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 53: invalid start byte

got the above error

pipreqs ./ --encoding=utf-8

jjhesk commented 1 year ago

thanks, I will come back and make a try.

mimi2626 commented 11 months ago

it doesn't solve it for me. "pipreqs ./ --encoding=utf-8" gives the same error again.

alan-barzilay commented 11 months ago

You have to figure out your file encoding to fix this issue, it is using a character not recognized by the default encoding. A good first attempt is to try utf-8, if it didnt work maybe try some encoding from your region. This is not something we can really help you with, sorry