question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeDecodeError: 'utf-8' codec can't decode byte

See original GitHub issue

I just installed pipreqs for the first time. This is what it does:

$ pipreqs $(pwd)
Traceback (most recent call last):
  File "/Users/tillmann/dev/textSum/.direnv/python-3.8.3/bin/pipreqs", line 10, in <module>
    sys.exit(main())
  File "/Users/tillmann/dev/textSum/.direnv/python-3.8.3/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 470, in main
    init(args)
  File "/Users/tillmann/dev/textSum/.direnv/python-3.8.3/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 406, in init
    candidates = get_all_imports(input_path,
  File "/Users/tillmann/dev/textSum/.direnv/python-3.8.3/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 122, in get_all_imports
    contents = f.read()
  File "/usr/local/bin/../Cellar/python@3.8/3.8.3_2/bin/../Frameworks/Python.framework/Versions/3.8/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 81: invalid start byte

Am I doing something wrong?

$ neofetch           
                    'c.          tillmann@MacBook-Pro 
                 ,xNMM.          -------------------- 
               .OMMMMo           OS: macOS Catalina 10.15.5 19F101 x86_64 
               OMMM0,            Host: MacBookPro15,1 
     .;loddo:' loolloddol;.      Kernel: 19.5.0 
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 17 days, 14 hours, 5 mins 
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 115 (brew) 
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.7.1 
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1680x1050@2x, 3840x1600@2x, 1050x1680@2x 
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua 
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor 
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Light) 
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: Apple_Terminal 
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   Terminal Font: HackNerdFontComplete-Regular 
    kMMMMMMMMMMMMMMMMMMMMMMd     CPU: Intel i7-8850H (12) @ 2.60GHz 
     ;KMMMMMMMWXXWMMMMMMMk.      GPU: Intel UHD Graphics 630, Radeon Pro 560X 
       .cooc,.    .,coo:.        Memory: 10080MiB / 16384MiB 
$ python -V                      
Python 3.8.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

11reactions
Teraskullcommented, Jul 24, 2020
$ pipreqs --encoding utf-8
8reactions
AgaMikocommented, Apr 25, 2022

I had a .venv directory with the usual hugh collection of python files. Something in the package black.py messed it up. A rm -rf .venv, and “pipreqs .” worked.

Thank you sir - this finally fixed my issue

Adding ignore parameters also work fine and you don’t have to remove virtual env!

pipreqs . --ignore ".env"

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
Sometimes I get characters like this œ that cause the UnicodeDecodeError error. I need to be able to make the string UTF-8 with...
Read more >
Python3 Fix→ UnicodeDecodeError: 'utf-8' codec can't decode ...
Open your CSV in Sublime Text/Notepad · Go to File → Save With Encoding (Save As in Notepad) · Select UTF-8 for your...
Read more >
UnicodeDecodeError utf-8 codec can t decode byte in position ...
UnicodeDecodeError utf-8 codec can t decode byte in position invalid start byte. +2 votes. While I importing the file it shows
Read more >
'utf8' codec can't decode byte 0xa5 in position 0: invalid start ...
Often, while reading the input files, you might encounter an UnicodeDecodeError. · Thus, the error means that the byte 0xa05 at position 0...
Read more >
'utf-8' codec can't decode byte 0xff in position 0 | bobbyhadz
The Python "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte" occurs when we specify an incorrect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found