Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipreqs: UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1206: character maps to <undefined>

When I use pipreqs, I have this problem. I use anaconda and Russian Windows.

root@DESKTOP-ETLLRI1 C:\Users\root\Desktop\resumes
$ pipreqs C:\Users\root\Desktop\resumes
Traceback (most recent call last):
  File "C:\Users\root\Anaconda3\Scripts\pipreqs-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 396, in main
    init(args)
  File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 341, in init
    extra_ignore_dirs=extra_ignore_dirs)
  File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 75, in get_all_imports
    contents = f.read()
  File "C:\Users\root\Anaconda3\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1206: character maps to <undefined>
like image 234
krax1337 Avatar asked Jul 24 '18 16:07

krax1337


1 Answers

You can pass an encoding argument to pipreqs to set the encoding to use to open files.

Python3 files are usually encoded as utf-8, so execute

pipreqs --encoding=utf8 C:\Users\root\Desktop\resumes

like image 86
snakecharmerb Avatar answered Sep 18 '22 16:09

snakecharmerb