LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-08-2018, 12:47 PM   #1
Chris.Bristol
Member
 
Registered: Jul 2011
Distribution: Ubuntu 20.04
Posts: 235

Rep: Reputation: 14
Snap and Python, GTK.


I've created a Snap for my Python program, which runs fine and can be installed from a .deb. It has these statements:
Code:
from PIL import Image
from gi.repository import Gtk, GdkPixbuf
So I have this in the .yaml:
Code:
stage-packages:
    - python3
    - python3-pil
    - python3-gi
    - gir1.2-gtk-3.0
    - gir1.2-gdkpixbuf-2.0
It doesn’t seem to work though, trying to run the app, it errors:
Code:
chris@Dell-DXP051:~/myapp$ myapp
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 890, in _find_spec
AttributeError: 'DynamicImporter' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "myapp.py", line 125, in <module>
    from gi.repository import Gtk, GdkPixbuf
  File "/snap/myapp/x11/usr/lib/python3/dist-packages/gi/importer.py", line 127, in find_module
    'introspection typelib not found' % namespace)
ImportError: cannot import name Gtk, introspection typelib not found
chris@Dell-DXP051:~/myapp$
I've no idea how to find out what is missing and there doesn't seem to be an active GTK forum.

Last edited by Chris.Bristol; 02-08-2018 at 12:58 PM.
 
Old 01-10-2019, 02:37 PM   #2
Chris.Bristol
Member
 
Registered: Jul 2011
Distribution: Ubuntu 20.04
Posts: 235

Original Poster
Rep: Reputation: 14
The PIL import works (I'd edit it out of the OP but it's not permitted).

However, nearly a year on, and I still haven't worked out how to import the GTK I've now tried a snapcraft.yanl copied from another post, but that doesn't work either. Surely someone must know how to create a Python+GTK Snap?

Code:
apps:
  myapp:
    command: python3 $SNAP/myapp.py
parts:
  myapp:
    source: .
    plugin: dump
 
parts:
  myapp:
    # See 'snapcraft plugins'
    plugin: python
    python-version: python3
    source: .
    build-packages: [python3-gi, python3-requests, gir1.2-gtk-3.0]
    stage-packages: [python3-gi, python3-requests, gir1.2-gtk-3.0]
    after: [desktop-gtk3]

Last edited by Chris.Bristol; 01-11-2019 at 09:42 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python/Gtk3: dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) RockDoctor Programming 2 08-12-2014 07:37 AM
[SOLVED] Python/GTK lambo69 Slackware 4 10-11-2012 08:06 AM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
snap/gtk gaah Programming 1 12-12-2004 05:10 PM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration