playitslowly icon indicating copy to clipboard operation
playitslowly copied to clipboard

AttributeError: 'gi.repository.Gtk' object has no attribute 'STOCK_CANCEL'

Open ghost opened this issue 2 years ago • 4 comments

I downloaded version 1.5.1 from https://29a.ch/playitslowly/playitslowly-1.5.1.tar.gz and installed on Ubuntu 22.04.

I installed as described in Generic Installation section of the README.

When I try to launch, I get the following error:

$ playitslowly
/home/user/playitslowly-1.5.1/playitslowly/app.py:36: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '4.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk, GObject, Gst, Gio, Gdk
/home/user/playitslowly-1.5.1/playitslowly/app.py:38: PyGIDeprecationWarning: Since version 3.11, calling threads_init is no longer needed. See: https://wiki.gnome.org/PyGObject/Threading
  GObject.threads_init()
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/user/playitslowly-1.5.1/playitslowly/app.py", line 41, in <module>
    from playitslowly.pipeline import Pipeline
  File "/home/user/playitslowly-1.5.1/playitslowly/pipeline.py", line 33, in <module>
    from playitslowly import myGtk
  File "/home/user/playitslowly-1.5.1/playitslowly/myGtk.py", line 29, in <module>
    buttons_ok_cancel = (Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK)
  File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 32, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 123, in __getattr__
    raise AttributeError("%r object has no attribute %r" % (
AttributeError: 'gi.repository.Gtk' object has no attribute 'STOCK_CANCEL'

ghost avatar Jun 01 '22 18:06 ghost

I think the most likely problem here is that you are running GTK4 rather than 3. I don't plan to work on playitslowly anymore since I've written Timestretch Player since.

I'll add a note to the README though to make this clear to people looking at the project.

Sorry for the hassle I caused you.

jwagner avatar Jun 05 '22 13:06 jwagner

Timestrech Player looks great. Thanks for all the software you've created and made freely available. There's no hassle in that ;)

ghost avatar Jun 08 '22 08:06 ghost

It's a pity that it's not developed anymore. It has been my primary guitar teaching tool for over eight years. Timestretch is not a real option because I need to use it even when there is no internet available. Maybe there was a chance to compile to a standalone version, snapcraft, flatpak or AppImage... Version 1.5 continues to work on Xubuntu 22.04. If it continues to be developed by someone else, please announce it here. Thank you very much for all the effort made.

nazarux avatar Jun 08 '22 15:06 nazarux

Problem

I also have been using this simple and very useful tool for a long time. After upgrading Ubuntu I got:

playitslowly/app.py:36: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '4.0') before import to ensure that the right version gets loaded. from gi.repository import Gtk, GObject, Gst, Gio, Gdk ... AttributeError: 'gi.repository.Gtk' object has no attribute 'STOCK_CANCEL'

possible fix

on Ubuntu 22.04 and Ubuntu 22.10 the simple insertion of "gi.require_version('Gtk', '3.0')" seems to do the job:

locate playitslowly/app.py

diff --git a/playitslowly/app.py b/playitslowly/app.py

index 32ad43b..58ae62c 100755
--- a/playitslowly/app.py
+++ b/playitslowly/app.py
@@ -31,6 +31,7 @@ except ImportError:
     import simplejson as json

 import gi
+gi.require_version('Gtk', '3.0')
 gi.require_version('Gst', '1.0')

On Ubuntu 22.10 playitslowly does not seem to be in the package list anymore. Thus, I cloned and modified the code:

# download code
git clone https://github.com/jwagner/playitslowly.git
cd playitslowly/playitslowly
git checkout -b fixit
nedit app.py

# run install.sh or directly run the program either with
python3 app.py
# or
../bin/playitslowly

I have only tested that the app runs and is able to play a song.

Github6am avatar Mar 26 '23 19:03 Github6am