Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web: import toga ModuleNotFoundError: No module named 'toga' #977

Closed
tmarkettos opened this issue Nov 24, 2022 · 1 comment
Closed

Web: import toga ModuleNotFoundError: No module named 'toga' #977

tmarkettos opened this issue Nov 24, 2022 · 1 comment
Labels
bug A crash or error in behavior.

Comments

@tmarkettos
Copy link

Describe the bug
In the absence of a tutorial for the web version, I tried replacing 'android' with 'web' from the tutorial. Things looked like they were working, but when I visit http://127.0.0.1:8080/ (Firefox, Ubuntu 22.04) I get the 'Loading runtime' spinner for a few seconds, and then this is displayed in the browser window (all on one line, linebreaks added)

PythonError: Traceback (most recent call last):
File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 506, in eval_code_async await CodeRunner( 
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 357, in run_async coroutine = eval(self.code, globals, locals) 
File "", line 2, in 
File "/lib/python3.10/runpy.py", line 209, in run_module return _run_module_code(code, init_globals, run_name, mod_spec)
File "/lib/python3.10/runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals,
File "/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals)
File "/lib/python3.10/site-packages/helloworld/__main__.py", line 1, in from helloworld.app import main
File "/lib/python3.10/site-packages/helloworld/app.py", line 4, in 
import toga ModuleNotFoundError: No module named 'toga' 

To Reproduce

mkdir beeware-tutorial
cd beeware-tutorial
python3 -m venv beeware-venv
source beeware-venv/bin/activate
python -m pip install briefcase
briefcase new # accept all the defaults
cd helloworld
briefcase create web
briefcase build web
briefcase run web

Expected behavior
I'd expect the 'Hello World' app to do something in the browser window.

Screenshots

(beeware-venv) ~/beeware/beeware-tutorial/helloworld$ briefcase create web

[helloworld] Generating application template...
Using app template: https://github.com/beeware/briefcase-web-static-template.git, branch v0.3.11
Using existing template (sha 207e5999090f1d532ad7a1cdb2df38b19d369469, updated Thu Oct  6 14:45:08 2022)

[helloworld] Installing support package...
No support package required.

[helloworld] Installing dependencies...
Writing requirements file... done

[helloworld] Installing application code...
Installing src/helloworld... done

[helloworld] Installing application resources...
Unable to find src/helloworld/resources/helloworld-32.png for 32px application icon; using default

[helloworld] Removing unneeded app content...
No app content clean up required.

[helloworld] Created web/static/Hello World
(beeware-venv) ~/beeware/beeware-tutorial/helloworld$ briefcase build web


[helloworld] Building web project...
Removing old wheels... done
Repacking wheel as ~/beeware/beeware-tutorial/helloworld/web/static/Hello World/www/static/wheels/helloworld-0.0.1-py3-none-any.whl...OK
Building app wheel... done
Collecting toga-web>=0.3.0.dev38
  Using cached toga_web-0.3.0.dev39-py3-none-any.whl (12 kB)
Saved ./web/static/Hello World/www/static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl
Installing wheels for dependencies... done
Writing Pyscript configuration file... done
Compile static web content from wheels
  Processing helloworld-0.0.1-py3-none-any.whl...
  Processing toga_web-0.3.0.dev39-py3-none-any.whl...
    Found toga_web/static/toga.css
Compiling static web content from wheels... done

[helloworld] Built web/static/Hello World/www/index.html
(beeware-venv) ~/beeware/beeware-tutorial/helloworld$ briefcase run web

[helloworld] Starting web server...
Web server open on http://127.0.0.1:8080

[helloworld] Web server log output (type CTRL-C to stop log)...
===========================================================================
127.0.0.1 - - [24/Nov/2022 18:57:45] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Nov/2022 18:57:45] "GET /static/css/briefcase.css HTTP/1.1" 200 -
127.0.0.1 - - [24/Nov/2022 18:57:46] "GET /pyscript.toml HTTP/1.1" 200 -
127.0.0.1 - - [24/Nov/2022 18:57:48] "GET /static/wheels/helloworld-0.0.1-py3-none-any.whl HTTP/1.1" 200 -
127.0.0.1 - - [24/Nov/2022 18:57:48] "GET /static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl HTTP/1.1" 200 -

Environment:

  • Operating System: Ubuntu 22.04
  • Python version: 3.10
  • Software versions:
    • Briefcase: 0.3.11
    • Toga: 0.3.0.dev39

Additional context
I think Beeware is brilliant :-)

@tmarkettos tmarkettos added the bug A crash or error in behavior. label Nov 24, 2022
@freakboy3742
Copy link
Member

Thanks for the report! It turns out this is actually a bug in Toga, not Briefcase; the toga-web 0.3.0.dev39 package didn't list toga-core as a dependency. As a workaround, you can modify the web configuration section of your project to read:

[tool.briefcase.app.helloworld.web]
requires = [
    'toga-core>=0.3.0.dev38',
    'toga-web>=0.3.0.dev38',
]
style_framework = "Bootstrap v4.6"

This problem has been fixed in Toga, so once the version of Toga is released, this workaround won't be needed any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

2 participants