I run a python application which uses a glade builder file for its GUI.
I recently migrated to a KDE desktop (Debian Wheezy). After installing the Gtk bindings with apt
(gir1.2-gtk-3.0) I tried to following error message when starting the Python
code:
gi._glib.GError: XXX.glade: required gtk+ version 3.10, current version is 3.4
How could I best solve this?
Do I need to downgrade Gtk from 3.4 to 3.1? And if yes how do I do that?
How do I find version 3.10 in the repositories?
Or is something wrongly configured? Maybe the Gtk version being fixed in the
glade file which I imported from a different system, whose Gtk version might
have been different (do not remember)?
Or any other suggestions?
I do not think source code is helpful in this matter, as the problem most likely is located outside of it, nonetheless some extract from it:
from gi.repository import Gtk, GObject, GLib
wTree = Gtk.Builder()
class Test_GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("XXX.glade")
self.window = self.builder.get_object("MainScreen")
self.window.show_all()
OK, the solution was to recompile the .glade builder file.
Somehow the version conflict was that the glade file was created on
a different system than it got used at.
Can you tell us wich program you try to use ? Can you Modify the source code to fit with your Gtk version ? Does it work ?
The upgrade from Gtk 3.4 to 3.10 is not possible (with aptitude or apt-get); Gtk 3.10 can't be found in the official repository of debian (correct me if i'm wrong), see this link
However you can install a later unstable version, see this link (It's not recommand too).
Related
I'm learning Tkinter right now and trying to work through my first issue, but finding Google hasn't been helpful.
I'm running this code on Mac OS X 10.15.1 (Catalina)
I'm using Python 3.7 and my code looks like so (lots of boilerplate per PEP8 standards):
"""
Experiments in tkinter
"""
import tkinter as tk
def main():
"""
Main entrypoint
"""
tk._test()
if __name__ == "__main__":
main()
This outputs the following warning to the console:
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
It also displays a window with completely blank buttons:
From my understanding these buttons should say "Click Me" and "Quit".
Also when I click on the top button it flashes black for a second like so:
After which the button is wider than before:
I assume the Tk version error may be related to the output behavior. However I can't seem to find a way to update Tk. What should I do here?
Update
After seeing #ShayneLoyd's answer (suggesting I needed an updated version of Python with an updated version of Tk) I began looking around some more and found this post on the Apple Discussion Boards which suggests you can use homebrew to install a version of Python which link's homebrew's own installed version of Tk. I tried this and it failed, so I Google'd the issue and found this StackOverflow post which seemed to suggest I can install
ActiveTcl and it will work.
I installed ActiveTcl from ActiveState and went back to my project. At first, I ran it like so:
$> cd ~/Source/experiments/python/tkinter
$> ./test.py
This actually worked! I could read the buttons and it behaved like it should. Then I realized I was not using pipenv, so I did a quick test:
$> pipenv run ./test.py
Now I was back to the failure state. I updated my script to display the Tcl and Tk version and sure enough when I used pipenv it was loading Tcl/Tk 8.5.9 but when I didn't use pipenv it was loading 8.6.9
So how do I fix pipenv now?
For anyone who's having the same issue and cannot switch Python version, you can easily bypass the "not showing text on buttons" problem by changing MacOs theme. System Preferences>General>Light Mode.
You should have in mind that you may encounter other problems.
After a few hours messing with it I figured it out!
The Pipfile contained a reference to Python version 3.7
Therefore pipenv install was searching my machine for any 3.7 version of Python installed. The version it found was Homebrew's, which has Tk 8.5.9 statically linked.
By updating the Pipfile to require Python 3.8 my machine started pulling my system Python, which uses the dynamically linked Tk, which I had successfully updated to 8.6.9
I can not import modules from gi.repository.
Specifically not Gtk and GObject.
I experienced this error both on Ubuntu 14.04 LTS and after reinstall
also on Linux Mint 17.
from gi.repository import Gtk, GObject
Results in the 'unresolved reference' warning for the respective
modules. Interestingly enough my Gtk GUI can be compiled and works
perfectly fine. Yet, GObject is entirely out of function.
I tried to work around with altering import statements such as:
from gi.repository.Gtk import*
Even hard coding the import path via:
sys.path.append('/usr/lib/python2.7/dist-packages/gi')
None of these approaches have solved this frustrating error so far.
I have not found any concluding help or basic info on this issue,
neither anywhere on the web nor in Linux forums or here on stackoverflow.
I am not sure whether this problem lies on the Python or the Linux side of things.
Can anybody suggest how to solve this issue?
What additional information do I need to provide eventually.
Thanks!
If on a Debian-based system such as Ubuntu, you probably need to install the gir1.2-gtk-3.0 package and other similarly named packages for other libraries. I don't know what the name of the package would be on Mint, but it's probably something similar.
On Wheezy (Debian 7.8) installing python3-gi fixed the problem for me.
I stumbled upon this issue with some old github python examples and it helped for me to add lines:
import gi
gi.require_version("Gtk", "3.0")
reference:
https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
I've just installed wxPython with no problems. I'm on a Snow Leopard Mac using Python 2.6 and downloaded the corresponding wxPython version.
I've started by typing a very basic wxPython app, but I'm getting the following error:
ImportError: No module named wx
The code is the following:
import wx
class Application(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Hello World', size = (300, 200))
if __name__=='__main__':
app = wx.PySimpelApp()
frame = Application(parent = None, id = 1)
frame.Show()
app.MainLoop()
Am I using a wrong version of Python, is it a 32/64-bit situation bug? If so, how do I solve it?
EDIT: Forced python to run at 32-bit, the issue sustains.
You can't use wxPython in 64-bit mode. First, force Python to use the 32-bit binary:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
Then you can use the builtin Python and the builtin wxPython.
Ok, the problem was I was running python 2.5.
To all MacOSX users who get stuck trying to install wxPython or any other python module: make sure your Python version is the same as the requested by the module. The python version included in MacOS tends to be older than the last stable one.
Thank you to all who helped me out.
I'm pretty sure you're not supposed to use the standard MacPython install with wxPython, but I don't have a Mac, so I'm not sure...FYI: The cocoa build of wxPython DOES support 64-bit mode, though.
I've had some problems installing QT on Snow Leopard and I'm hoping that I can benefit from someone else who's been in this position. :)
I'm assuming that I'll need to use a version of python that's not included with SL... be it from homebrew, macports, python.org, etc.
Can anyone give me some simple steps to follow to get QT, PyQT, and PySide installed? Bonus points for an example of how to setup a project to use py2app with all this.
Thanks! :)
If you want to try out PySide, you can follow these steps:
http://blogger-mikael.blogspot.com/2010/09/compiling-pyside-for-qt-47-on-os-x.html
Just use a binary distribution of PyQt + Qt + Python for OS X, and then install PySide manually. For example, there's: http://sourceforge.net/projects/pyqt-mac/files/ , but it appears that the associated web site has vanished.
Just wondering though, why would you use both PyQt and PySide?
If you want to install QT on Snow Leopard, this might help you...
According to this bug report, the 4.8.0 release was bundled for OS X Lion only. Using the 4.8.0 release will result in errors like:
dyld: Symbol not found: _kCFWebServicesProviderDefaultDisplayNameKey
Referenced from: /Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit
Expected in: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
In other words, you will need to use the 4.7.0 release until this is remedied. Homebrew is referencing 4.8.0, so you'll have to use the standalone installer. Here is the link for the QT 4.7.0 Snow Leopard installer.
In regards to PyQT and PySide, I can't help you there. I don't know anything about Python. =/
It seems that regarding Qt 5.x on SL, you need to compile it.
This page explains how to do so.
However, having first installed the latest XCode 3.2.6 on SL, the setup runs smoothly. It's only when running Qt Creator that a few error messages start to appear:
Symbol not found: _kCFWebServicesProviderDefaultDisplayNameKey...
Plugin initialization failed...
I have an application which depends on PyGTK, PyGobject, and PyCairo that I built to work on Linux. I want to port it over to windows, but when I execute import gobject I get this:
Traceback (most recent call last):
import gobject
File "C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 30, in <module>
from gobject.constants import *
File "C:\Python26\lib\site-packages\gtk-2.0\gobject\constants.py", line 22, in <module>
from _gobject import type_from_name
ImportError: DLL load failed: The specified procedure could not be found.
This appears to be caused by the switch from building using MinGW to Microsoft Visual Studio, as documented Python Bug 3308 (closed: wontfix).
Is there any way to install PyGTK/PyGObject in a way that will work with Python 2.6 on Windows, without having to recompile one or the other from source?
I have it working fine, and it didn't give me much trouble, so we know it can be done...
Keep in mind you will probably need all of the following installed on your Windows machine:
PyCairo ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/ )
PyGobject ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/ )
PyGTK ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/ )
Unofficial x64 versions of the above 3 items are available here -- However, I cannot vouch for nor recommend them!
and of course
the GTK+ Runtime ( http://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/ or http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/ )
I suspect in your case that the PyGTK libraries are not finding your GTK+ Runtime directory where the DLLs are. You should have the environment variable GTK_BASEPATH set to the directory of your GTK+ Runtime (usually C:\GTK).
Please also see the PyGTK-on-Windows FAQ
Now, if you're trying to compile the PyGTK'ed Python with Py2EXE, that's a bit more complicated, but it can be done as well...
The PyGTK all-in-one installer has been updated recently:
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/
This will install PyGTK, PyGObject, PyCairo, PyGtkSourceView2, PyGooCanvas, PyRsvg, the gtk+-bundle and Glade. It is absolutely everything necessary to be able to successfully import gobject, import gtk, etc, without DLL problems.
for 64 bit Windows users see
http://digitalpbk.blogspot.in/2012/03/installing-pygtk-pypango-and-pycairo-on.html
Above steps will give Invalid DLL error on 64 bit.
u should have pygtk,pycairo,pygboject and the gtk+ runtime...
see this for an all in one installer
http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html
Be careful about installing PyGTK bundle pack if any one planning to run PyGTK through embedded interpreter and the C/C++ code is already using GTK. PyGTK bundle pack does not add its GTK runtime to PATH.
In such case possibly the C code will take GTK from PATH (as probably you have already installed GTK bundle pack) and Python will use separate set of GTK runtime libraries.
Therefore in my case either C GUI or Python GUI used to run properly and used to conflict while running together.
As I use Psychopy as my base python collection, to solve this problem I have just installed PyGTK PyGTK, Pycairo, Pygobject on top of Psychopy.
Apart from using only one set of GTK runtime I had to initialize GTK in my C code through PyGTK (not by gtk_init (&argc, &argv) in my C code) after initializing python interpreter.