Str' Object Has No Attribute 'Decode'. Python 3 Error

str' object has no attribute 'decode'. Python 3 error?

You are trying to decode an object that is already decoded. You have a str, there is no need to decode from UTF-8 anymore.

Simply drop the .decode('utf-8') part:

header_data = data[1][0][1]

Python AttributeError: 'str' object has no attribute 'decode'

To quote from an existing answer to a similar problem:

You are trying to decode an object that is already decoded. You have a str, there is no need to decode from UTF-8 anymore.

Specific to your question, here is the problem:

    data = str(data)
print(data.decode('utf-8'))

data = str(data) has already converted data to a string and then you're trying to decode it again using data.decode(utf-8').

The solution is simple, simply remove the data = str(data) statement (or remove the decode statement and simply do print(data))

AttributeError: 'str' object has no attribute 'decode' in fitting Logistic Regression Model

I tried to upgrade my scikit-learn using the below command, still, that didn't solve the AttributeError: 'str' object has no attribute 'decode' issue

pip install scikit-learn  -U

Finally, below code snippet solved the issue, add the solver as liblinear

model = LogisticRegression(solver='liblinear')

Does Any one got AttributeError: 'str' object has no attribute 'decode' , while Loading a Keras Saved Model

For me the solution was downgrading the h5py package (in my case to 2.10.0), apparently putting back only Keras and Tensorflow to the correct versions was not enough.



Related Topics



Leave a reply



Submit