I am trying to follow a tutorial found here to calibrate a camera via a chessboard image, using python and opencv in Ubuntu 18.04. Everything goes well until the program gets to the cv2.imshow() function, at which point I get the following error:
Gtk-ERROR **: 19:31:06.612: GTK+ 2.x symbols detected. Using GTK+ 2.x
and GTK+ 3 in the same process is not supported Trace/breakpoint trap
(core dumped)
I can only get around this error by commenting out the function. As I am quite new to programming, I don't know how to troubleshoot this further. Searching for this error online shows it being encountered in scenarios different from mine. I would really appreciate any help in resolving this. Please let me know if more information is needed.
The error message is telling you that you're trying to load two different major versions of GTK in the same process—either because you're importing the Gtk module like:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
or because the OpenCV Python module is trying to side-load a GTK module by itself. Since OpenCV seems to use Qt, it might be a case of a GTK module being loaded in your environment to match the system's style.
Related
I was using Raspberry Pi to perform some basic experiments and I wrote some Python scripts for that and they were fine. Then, for a new part of the analysis, I had to import SciPy. To be able to use SciPy, I had to install an older version. After that, I'm getting "ImportError" for every module. For example:
ImportError: cannot import name 'process' from partially initialized module 'multiprocessing' (most likely due to a circular import)"
Some people said it might be because of having the same script filename which will conflict with the multiprocessing module but this is not true in my case.
Also, I tried the analysis part of the code on different systems (Ubuntu on my laptop) and it works fine so I'm sure there is nothing wrong with the code.
I'm wondering if anyone else has ever had the same issue on Raspberry Pi?
Best regards,
Amir
So, i installed some stuff for python, and going through all my imports and trying to pip install them gives me a 'Requirement already satisfied'. When I run a script though, everytime i debug to
import vlc
I get a
OSError: [WinError 126] The specified module could not be found
directly instead of passing through to the next import. if i comment out this import, it works up to the point where I use it. I am using VSCode, my python version is set to 3.7.1, so that is not the problem. I rarely work with python, so I do not know what else I can do at this point.
While obvious to some, I did not know that VLC was Traffic Cone (tm) video player, and probably should have read the vlc docs.
You need to have the actual VLC installed on you PC for the vlc import to work with python
I researched and tried this for two days now and I cannot get gtk to work on Windows 7 with Python 3.4! Whenever I launch my .py file on Python 3.4 with import gtk, I get No module named gtk! I installed pygobject but it did not help. Even gtk3-demo command works in the windows cmd prompt.
I finally got gtk to import (I think) by copying the GTK directory right to C:\Python34\Lib. But now I have a problem with gtk.glade.
Where is this? Where do I copy it from and to where?
You are possibly using an outdated tutorial, see the current Python GTK 3 tutorial for a more up-to-date reference.
In particular, the way to import GTK has changed in GTK3 to:
from gi.repository import Gtk
And instead of libglade, you would use the newer Gtk.Builder class like so:
ui = Gtk.Builder()
ui.add_from_file("my_glade_file.glade")
(you still develop the UI using Glade, it is only how you access it from your program that has changed).
I was trying to do gui programming in Python.I figured out that PySide is a good framework to start with.As i was running Python 2.7.2 i downloaded PySide 2.7 and tried running a sample app.I got QtCore Library not loaded error.
This is the error that i got..
from PySide import QtCore, QtGui
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2):
Library not loaded: QtCore.framework/Versions/4/QtCore
Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
Reason: image not found
I googled and found out that many people were facing the same issue and i saw solutions being posted based on exporting DYLD_FRAMEWORK_PATH. I was not able to follow this.
Could anyone please tell me whats the issue and how to fix it!!
Thanks..
You don't mention the OS you are working on, but from the paths in your error message it looks like you're on Mac OSX.
I'm not an expert in PySide at all, but I had the same problem a while ago and I think I know what's going on: The library at /Library/Python/2.7/site-packages/PySide/QtCore.so is the part that makes the Qt Core C++ library available to Python. It is just the wrapper though or some sort of translator between C++ and Python, the actual C++ functionality is elsewhere - and when the Python interpreter tries to load the C++ library that contains that functionality from QtCore.framework/Versions/4/QtCore, if fails to find it, hence the error message.
A quick and dirty way to solve your problem is to create symbolic links from the location where QtCore.so expects the C++ library to where it actually is. For that, you will obviously have to find the C++ library. If you downloaded Qt 4.8.4 as an installer from the Qt Project page, the libraries AFAIK are somewhere in /usr/lib, so you would create a symlink like this:
ln -vis /usr/lib/<insert subfolder>/QtCore.framework /Library/Python/2.7/site-packages/PySide/QtCore.framework
You will have to do this in a similar way for QtGui and any other Qt library you want to use as well. Note that this obviously does not symlink the library itself, but the folder in which QtCore.so expects it.
An alternate way would be to build PySide from the sources (which is what I ended up doing), but that takes longer - and you sound like you just want to get going with Python and Qt.
Have you installed standalone QT package for mac?
Qt for Mac OS X: Download Qt 4.7.4 ftp://ftp.qt-project.org/qt/source/qt-mac-opensource-4.7.4.dmg standalone pyside installation raises same error log for me
On Fedora 16, I have a catalog library of widgets that I wish to load into glade. Normally, this should be easy but since I have different versions of glib and gobject installed, the following error occurs:
; GLADE_CATALOG_PATH=./Components GLADE_MODULE_PATH=. glade fubar.glade
(glade:25069): GladeUI-PYTHON-WARNING **: Error initializing Python interpreter: could not import pygobject
(glade:25069): GladeUI-PYTHON-WARNING **: Unable to load pygobject module >= 2.90.0, please make sure it is in python's path (sys.path). (use PYTHONPATH env variable to specify non default paths)
could not import gobject (version mismatch, 2.90.0 is required, found 3.0.3)
zsh: segmentation fault (core dumped) GLADE_CATALOG_PATH=./Components GLADE_MODULE_PATH=. glade
Is there a way to force a version of gobject? Currently, I have this installed:
; yum list installed | grep pygobject
pygobject2.x86_64 2.28.6-2.fc16 #anaconda-0
pygobject2-codegen.x86_64 2.28.6-2.fc16 #fedora
pygobject2-devel.x86_64 2.28.6-2.fc16 #fedora
pygobject2-doc.x86_64 2.28.6-2.fc16 #fedora
pygobject3.x86_64 3.0.3-1.fc16 #updates
I ran into this issue as well. The problem is that the version check is wrong, pyobject3 is just fine for the glade Python plugin. Patch is here:
https://bugzilla.gnome.org/show_bug.cgi?id=706304. I don't know any fix other than recompiling glade, though.
This issue arises when using 3.10 (gtk3) instead of 3.8 (gtk2).