trainman419 / python-cec

Other
170 stars 42 forks source link

Please help fix error #57

Open Electrik-rich546456 opened 2 years ago

Electrik-rich546456 commented 2 years ago

Hi @trainman419 I hope you can help me fix this. I receive this error when trying the example code in the readme.

<module '_cec' from '/usr/lib/python3/dist-packages/_cec.cpython-38-x86_64-linux-gnu.so'>Exception "unhandled AttributeError" module 'cec' has no attribute 'init' File: /home/user/Documents/Python works/cec codes/my_pycecclient2.py, Line: 4

trainman419 commented 2 years ago

Hrm... that should work, because that API hasn't changed in a long time. Is it possible you have a different python cec module that might be getting loaded instead of this one?

Electrik-rich546456 commented 2 years ago

how do i find out if that is the case ? how do i change it back or make changes to the api ?

trainman419 commented 2 years ago

Typically, your version of Linux will have a package manager that is used to install system packages, including system-wide python packages. Python also has the PIP tool which can be used to install python packages.

You should check your system's package manager and PIP (try pip list) to see if there's another python CEC package installed.

Electrik-rich546456 commented 2 years ago

cec 0.2.7 no python-cec though.

trainman419 commented 2 years ago

It looks like you may also have the PulseEight python 3 CEC bindings installed through your package manager.

You haven't stated which linux distribution or package manager that you're using, so I can't really help you further with that.

Electrik-rich546456 commented 2 years ago

Oh sorry I'm running Ubuntu 20.04.3 LTS 64bit my package manager is apt get or synaptic package manager

trainman419 commented 2 years ago

It looks like the PulseEight CEC library is packaged as python3-cec for Ubuntu ( https://packages.ubuntu.com/focal/python/python3-cec ); you can check if that's installed with dpkg -l python3-cec

Electrik-rich546456 commented 2 years ago

oh i see... its not installed...oops {[( still a noob )}] so in your demo code i believe you import the same cec module the demo code from pulse-eight repo. if that is correct will installing this python3-cec mess up the demo code ? supplied in that repo? it may be a silly question but i'm still learning everyday. sorry if it is I hope not and understand how using your code will be a lot better/ easier less code. But i've been tinkering with the pyCecClient.py file
I wanted to have it switch hdmi sources and check power status and obviously turn on and off after power check so a power toggle function. can i do all that using your code bindings?

Electrik-rich546456 commented 2 years ago

I still get this error ./Test.py <module '_cec' from '/home/user/Ext-Space/DONE/UB Documents/Python works/cec codes/cec3_bindings/_cec.cpython-38-x86_64-linux-gnu.so'> Traceback (most recent call last): File "./Test.py", line 6, in <module> adapters = cec.list_adapters() AttributeError: module 'cec' has no attribute 'list_adapters' when running your test script

Electrik-rich546456 commented 2 years ago

./pyCecClient.py <module '_cec' from '/home/user/Ext-Space/DONE/UB Documents/Python works/cec codes/cec3_bindings/_cec.cpython-38-x86_64-linux-gnu.so'> <module 'cec' from '/home/user/Ext-Space/DONE/UB Documents/Python works/cec codes/cec3_bindings/cec.py'> libCEC version 4.0.4 loaded: git revision: libcec-4.0.4+1-ba9b538~dirty, compiled on Wed 12 Feb 13:45:05 UTC 2020 by user@user-pc on Linux 5.3.0-29-generic (x86_64), features: P8_USB, DRM, P8_detect, randr