-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: a bytes-like object is required, not 'str' #3
Comments
Resolved: It works with python2.7. It crashes with python3.8. This is because here at line 255:
python2.7 and python3.8 treats differently bytes and string. A possible solution to make it version independent would be to save somewhere the output of blastn and read it as tab separated values table. my two cents, |
The reason for this error is that in Python 3, strings are Unicode, but when transmitting on the network, the data needs to be bytes instead. We can convert bytes to string using bytes class decode() instance method, So you need to decode the bytes object to produce a string. In Python 3 , the default encoding is "utf-8" , so you can use directly:
Python makes a clear distinction between bytes and strings . Bytes objects contain raw data — a sequence of octets — whereas strings are Unicode sequences . Conversion between these two types is explicit: you encode a string to get bytes, specifying an encoding (which defaults to UTF-8); and you decode bytes to get a string. Clients of these functions should be aware that such conversions may fail, and should consider how failures are handled. |
a bytes-like object is required not 'str' simply add .decode() If keyword in load:
Error: if keyword in load: TypeError: a bytes-like object is required not 'str' solution: If keyword in load.decode():
For easy understanding click the below link: |
Dear Ryan,
referred to this klebgenomics/Kaptive#15 (comment):
gives me the following error:
Thank you!
-A
The text was updated successfully, but these errors were encountered: