toga icon indicating copy to clipboard operation
toga copied to clipboard

ModuleNotFoundError: No module named 'toga_gtk'

Open TBWarrington opened this issue 6 years ago • 4 comments

Current Behavior

Trying to run Hello World script on Linux (Ubuntu 18.04). I get the no module toga_gtk error. Script runs fine on Windows. All components are installed and apparently up to date (see version #s below). I am willing to accept user error if someone can give me some advice on resolving this. Thanks!

##Versions toga==0.3.0.dev18 toga-core==0.3.0.dev18 toga-gtk==0.3.0.dev18 Python 3.6.7

#Script

import toga

def button_handler(widget): print("hello")

def build(app): box = toga.Box()

button = toga.Button('Hello world', on_press=button_handler)
button.style.padding = 50
button.style.flex = 1
box.add(button)

return box

def main(): return toga.App('First App', 'org.beeware.helloworld', startup=build)

if name == 'main': main().main_loop()

TBWarrington avatar Feb 11 '20 17:02 TBWarrington

Could it be a GTK issue? Looks like I only have v3.22 installed. Is there a way to force linux to install GTK 3.4? Is it even possible give that my machine is >8 years old? Thanks!

libgtk-3-0:amd 3.22.30-1ubu amd64 GTK+ graphical user interface lib

TBWarrington avatar Feb 11 '20 17:02 TBWarrington

Thanks for the report - that is indeed very odd. I can't think of any obvious reason why you'd be getting an error finding toga-gtk when your virtual environment contains that package. The only two causes could be:

  1. You're not running your code in the environment or with the interpreter you think you are, or
  2. There's something very deeply wrong with your install of Toga.

Are you able to share the full stack trace? That might shed some more light on the failure.

Also, can you confirm how you determined what was installed - can you provide the output of python -m pip freeze?

freakboy3742 avatar Feb 11 '20 22:02 freakboy3742

Okay, I think I've solved it. I was trying to run it under my system python3 rather than in a virtual environment. I was checking installation using pip3 freeze rather than python3 -m pip freeze. Is there a substantial difference between the two? I could have sworn it showed up under pip3 but it didn't under python3 -m pip. Either way, I reinstalled using python3 -m pip and it seems to be working now. Thanks!

TBWarrington avatar Feb 12 '20 20:02 TBWarrington

Fantastic - glad to hear you sorted it out.

The major difference between pip3 freeze and python3 -m pip freeze is which python is being used to run the freeze. Brett Cannon did a really good writeup of the differences here.

I'm going to close this ticket since your problem seems to be resolved; if you hit any other problems, feel free to open another ticket.

freakboy3742 avatar Feb 12 '20 23:02 freakboy3742