Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pip

zeromq

I am going to install ZeroMQ library in my pc using pip package installer. I use https://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/basics.html#installation as my reference. After executing follwing command:

pip install pyzmq-static

I get this error:

C:\Users\MyName>pip install pyzmq-static
You are using pip version 7.0.1, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pyzmq-static
  Using cached pyzmq-static-2.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\MyName\AppData\Local\Temp\pip-build-m8zyvx48\pyzmq-static\
setup.py", line 6, in <module>
        long_description = open(os.path.join(os.path.dirname(__file__), 'README.
rst')
    AttributeError: 'str' object has no attribute 'decode'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\MyName\
AppData\Local\Temp\pip-build-m8zyvx48\pyzmq-static

My python version is 3.5 and I use windows 8.0 OS.

Update

I found that my referenced article has used python 2.X and I am using python 3.5.

like image 671
Seyed Morteza Mousavi Avatar asked Jun 19 '15 11:06

Seyed Morteza Mousavi


People also ask

How do I fix AttributeError str object has no attribute decode?

The Python "AttributeError: 'str' object has no attribute 'decode'" occurs when we call the decode() method on a string that has already been decoded from bytes. To solve the error, remove the call to the decode() method as the string is already decoded.

How to decode UTF 8 in Python?

To decode a string encoded in UTF-8 format, we can use the decode() method specified on strings. This method accepts two arguments, encoding and error . encoding accepts the encoding of the string to be decoded, and error decides how to handle errors that arise during decoding.

What does decode do in Python?

decode() is a method specified in Strings in Python 2. This method is used to convert from one encoding scheme, in which argument string is encoded to the desired encoding scheme. This works opposite to the encode. It accepts the encoding of the encoding string to decode it and returns the original string.

What is TypeError str object is not callable?

The result was the TypeError: 'str' object is not callable error. This is happening because we are using a variable name that the compiler already recognizes as something different. To fix this, you can rename the variable to a something that isn't a predefined keyword in Python. Now the code works perfectly.


1 Answers

Why are you using pyzmq-static ? According to this reference pyzmq-static is obsolete, the latest package for it was uploaded on 11-09-2012 , maybe it was not developed for python 3.x .

You should instead try using pyzmq (as even indicated by the pypi page for pyzmq-static) .

like image 197
Anand S Kumar Avatar answered Sep 29 '22 00:09

Anand S Kumar