jeffbass / imagezmq

A set of Python classes that transport OpenCV images from one computer to another using PyZMQ messaging.
MIT License
1.01k stars 160 forks source link

AttributeError: module 'imagezmq' has no attribute 'ImageSender' #21

Closed nandemoi closed 4 years ago

nandemoi commented 4 years ago

Sorry this must be pretty basic. When I tried to run client.py I got AttributeError: module 'imagezmq' has no attribute 'ImageSender'

As to where to place imagezmq, I've tried both (2) and (3) as prescribed in https://www.pyimagesearch.com/2019/04/15/live-video-streaming-over-network-with-opencv-and-imagezmq/

WORK-AROUND: I worked around it by soft link imagezmq.py to the directory where client.py is at and invoked. Would like to know the proper way to do it right, though.

jeffbass commented 4 years ago

Glad you found a work-around. Let me take a look at the link you provide and try to understand what the issue is. I'll post another comment in this thread in a few days after I have looked at it.

nandemoi commented 4 years ago

Thank you. Great work. Thanks for sharing.

I found it down below says

import imagezmq by from imagezmq import imagezmq

that resolved it.

ycdaskin commented 3 years ago

Still getting this error. What @nandemoi suggested did not work for me. Any solution for this?

jeffbass commented 3 years ago

Hi @ycdaskin, If you are getting this error, it is very likely that imagezmq has not been imported correctly. To use imagezmq, you need to create and use a Python virtual environment. OpenCV needs to be installed in the same virtual environment. In the rest of this post, I am assuming you have a virtual environment that has OpenCV already installed in it. Here is how to make sure that imagezmq has been installed correctly into that virtual environment:

# run these 2 commands at your system prompt
workon py3cv4  # my environment is named py3cv4; use your own virtual environment name
pip install imagezmq

Then, run Python interactively and import imagezmq and create an instance of the ImageSender class. Make sure all this is working without errors:

(py3cv4) pi@rpi24:~ $ python
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
>>> import imagezmq
>>> imagezmq.__version__
'1.1.1'
>>> sender = imagezmq.ImageSender()  # if you get an error here, imagezmq is not installed correctly
>>> type(sender)
<class 'imagezmq.imagezmq.ImageSender'>
>>> exit()
(py3cv4) pi@rpi24:~ $ 

Be sure that any Python programs that use imagezmq are run in this same virtual environment. I think that running the above commands should enable you to find and fix your error. Let me know if I can help further. Jeff