Error importing ZeroMQ Python module

I installed ZeroMQ by adding the official ZeroMQ repository to my sources, and then installed it through apt-get install libzmq3-dev, and then installed the module using apt-get install python-zmq.

When I open the python interpreter and type import zmq, I get the following error:

  Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "zmq.py", line 2, in <module>
    context = zmq.Context()
AttributeError: 'module' object has no attribute 'Context'

I'm not sure what I'm doing wrong. Any help would be greatly appreciated, thanks!

+4
source share
2 answers

Is it possible that you have a file in your project called zmq.py, and you accidentally import it?

You should always use absolute_import with Python 2.x (from PEP 328 ) to avoid these problems.

from __future__ import absolute_import
+2

,

apt-get install libzmq3

. -dev /​​ . , .

0

Source: https://habr.com/ru/post/1540973/


All Articles