libonvif icon indicating copy to clipboard operation
libonvif copied to clipboard

AttributeError: module 'libonvif' has no attribute 'Session'

Open SCORPIONZO opened this issue 6 months ago • 4 comments

File "/Users/kirillatabaev/miniconda3/lib/python3.12/site-packages/onvif_gui/init.py", line 1, in from .main import MainWindow File "/Users/kirillatabaev/miniconda3/lib/python3.12/site-packages/onvif_gui/main.py", line 33, in from onvif_gui.panels import CameraPanel, FilePanel, SettingsPanel, VideoPanel,
File "/Users/kirillatabaev/miniconda3/lib/python3.12/site-packages/onvif_gui/panels/init.py", line 1, in from .camera.camerapanel import CameraPanel File "/Users/kirillatabaev/miniconda3/lib/python3.12/site-packages/onvif_gui/panels/camera/init.py", line 7, in from .datastructures import Session, Camera File "/Users/kirillatabaev/miniconda3/lib/python3.12/site-packages/onvif_gui/panels/camera/datastructures.py", line 31, in class Session(onvif.Session): ^^^^^^^^^^^^^ AttributeError: module 'libonvif' has no attribute 'Session'

MacOs

SCORPIONZO avatar Jul 10 '25 22:07 SCORPIONZO

Thank you for reaching out, feedback is always appreciated. This type of error is usually associated with a failure of the compile process when building the application. There have been a few discussions around this topic as it has been a thorny issue. Long story short, there is a complex compilation process that requires a very specific configuration which can easily go wrong in a real world scenario. The solution is to build pre-compiled binary versions of the program that can be integrated into system specific installers. These are coming out very soon for all supported platforms, but there already is one out for the Mac. This should get you up and running with the current version. There is a new version coming very soon, probably in the next few days.

Looking at the output of the error command, I would guess that you are building the application from source code, which is prone to the problem you are experiencing. I'm wondering why this path might have been chosen over the packaged installer. Older versions of the program were installed by building from source, but there have been some advancements that have made that unnecessary. One thing you could try since you have python3.12 installed on the machine is to install directly from pip. You should be able to install Onvif GUI by setting up a virtual environment, then using pip to install.

conda create --name onvif-gui-env python=3.12
conda activate onvif-gui-env
pip install onvif-gui
onvif-gui

The installer is a better option, it will create an icon you can use from the Application Launcher.

If you are set on building from source, please note that the homebrew-ffmpeg version must be installed using homebrew before attempting the compilation. The Build From Source instructions on the homepage assume that you will be using xcode to compile, which has another necessary library, libxml2, included by default. The compilation itself is invoked using the pip command from a virtual environment that has been created the same as shown above. There are three python modules that need to be built in order for the application to work, libonvif, libavio and kanakee. These are subdirectories of the libonvif source code that will be present if git cloned using the --recursive flag. The modules can be built using the command pip install -v . from each of these subdirectories while in your virtual environment. If they are not working, look through the output of the command to find errors. Please let me know if you need further help getting started.

Best Regards,

Stephen

sr99622 avatar Jul 11 '25 14:07 sr99622

/Users/kirillatabaev/.zprofile:7: no such file or directory: /opt/homebrew/bin/brew /Users/kirillatabaev/.zprofile:9: no such file or directory: /opt/homebrew/bin/brew /Users/kirillatabaev/.zprofile:11: no such file or directory: /opt/homebrew/bin/brew /Users/kirillatabaev/.zprofile:13: no such file or directory: /opt/homebrew/bin/brew /Users/kirillatabaev/.zprofile:15: no such file or directory: /opt/homebrew/bin/brew kirillatabaev@192 ~ % python3 -m venv onvif-gui-env kirillatabaev@192 ~ % source onvif-gui-env/bin/activate (onvif-gui-env) kirillatabaev@192 ~ % pip install onvig-gui ERROR: Could not find a version that satisfies the requirement onvig-gui (from versions: none) ERROR: No matching distribution found for onvig-gui (onvif-gui-env) kirillatabaev@192 ~ % pip install onvif-gui Requirement already satisfied: onvif-gui in ./onvif-gui-env/lib/python3.12/site-packages (3.0.11) Requirement already satisfied: libonvif==3.2.6 in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (3.2.6) Requirement already satisfied: avio==3.2.6 in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (3.2.6) Requirement already satisfied: kankakee==1.0.3 in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (1.0.3) Requirement already satisfied: numpy in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (2.2.6) Requirement already satisfied: loguru in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (0.7.3) Requirement already satisfied: opencv-python-headless in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (4.12.0.88) Requirement already satisfied: PyQt6-Qt6 in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (6.9.1) Requirement already satisfied: pyqt6 in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (6.9.1) Requirement already satisfied: requests in ./onvif-gui-env/lib/python3.12/site-packages (from onvif-gui) (2.32.4) Requirement already satisfied: PyQt6-sip<14,>=13.8 in ./onvif-gui-env/lib/python3.12/site-packages (from pyqt6->onvif-gui) (13.10.2) Requirement already satisfied: charset_normalizer<4,>=2 in ./onvif-gui-env/lib/python3.12/site-packages (from requests->onvif-gui) (3.4.2) Requirement already satisfied: idna<4,>=2.5 in ./onvif-gui-env/lib/python3.12/site-packages (from requests->onvif-gui) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in ./onvif-gui-env/lib/python3.12/site-packages (from requests->onvif-gui) (2.5.0) Requirement already satisfied: certifi>=2017.4.17 in ./onvif-gui-env/lib/python3.12/site-packages (from requests->onvif-gui) (2025.7.9) (onvif-gui-env) kirillatabaev@192 ~ % onvif-gui Traceback (most recent call last): File "/Users/kirillatabaev/onvif-gui-env/bin/onvif-gui", line 5, in from onvif_gui.main import run File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/onvif_gui/init.py", line 1, in from .main import MainWindow File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/onvif_gui/main.py", line 33, in from onvif_gui.panels import CameraPanel, FilePanel, SettingsPanel, VideoPanel,
File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/onvif_gui/panels/init.py", line 1, in from .camera.camerapanel import CameraPanel File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/onvif_gui/panels/camera/init.py", line 7, in from .datastructures import Session, Camera File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/onvif_gui/panels/camera/datastructures.py", line 23, in import libonvif as onvif File "/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/libonvif/init.py", line 19, in sys.modules[name] = importlib.util.module_from_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ImportError: dlopen(/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/libonvif/libonvif.cpython-312-darwin.so, 0x0002): tried: '/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/libonvif/libonvif.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/libonvif/libonvif.cpython-312-darwin.so' (no such file), '/Users/kirillatabaev/onvif-gui-env/lib/python3.12/site-packages/libonvif/libonvif.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')) (onvif-gui-env) kirillatabaev@192 ~ % exit

Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

[Процесс завершен]

SCORPIONZO avatar Jul 11 '25 17:07 SCORPIONZO

The binaries for MacOS do not support Intel architecture. You could try compiling from source, but are likely to run into issues. You might try iSpy camera software, it has more supported platforms.

sr99622 avatar Jul 11 '25 18:07 sr99622

Thank you. That's feedback!

SCORPIONZO avatar Jul 11 '25 18:07 SCORPIONZO