Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

ImportError: No module named 'toga.style' #2

Closed
jedie opened this issue Mar 16, 2018 · 2 comments
Closed

ImportError: No module named 'toga.style' #2

jedie opened this issue Mar 16, 2018 · 2 comments

Comments

@jedie
Copy link
Contributor

jedie commented Mar 16, 2018

setup.py django -s build the "django app" here, but the dev server starts raise into ImportError: No module named 'toga.style'

...
 * Starting Django server on localhost:8042
 * Opening browser...
Performing system checks...

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 58, in execute
    super(Command, self).execute(*args, **options)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 97, in handle
    self.run(**options)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 108, in run
    self.inner_run(None, **options)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/base.py", line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/base.py", line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/urls/resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/jens/repos/RunCalculator-Env/django/briefcase/urls.py", line 27, in <module>
    url(r'', TogaApp('run_calculator').urls)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/toga_django/django/__init__.py", line 16, in TogaApp
    module = importlib.import_module(module_name + ".app")
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/jens/repos/RunCalculator-Env/src/run-calculator/run_calculator/app.py", line 13, in <module>
    from toga.style import Pack
ImportError: No module named 'toga.style'

Maybe it's related to: beeware/toga#315 (comment) ?

@jedie
Copy link
Contributor Author

jedie commented Mar 16, 2018

Hm. Think the problem is, that setup.py django -s will install older packages...

I start with:

pip freeze
...
-e git+https://github.com/pybee/briefcase.git@6ab9914cececeb71e5b1f034687f5943e154c071#egg=briefcase
...
-e [email protected]:jedie/RunCalculator.git@673bc84795c65952ba72a8daef376fc16644e1fe#egg=run_calculator
...
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_core&subdirectory=src/core
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_django&subdirectory=src/django
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_dummy&subdirectory=src/dummy
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_gtk&subdirectory=src/gtk
...

After running setup.py django -s i get this:

$ pip freeze
...
-e git+https://github.com/pybee/briefcase.git@6ab9914cececeb71e5b1f034687f5943e154c071#egg=briefcase
...
-e [email protected]:jedie/RunCalculator.git@673bc84795c65952ba72a8daef376fc16644e1fe#egg=run_calculator
...
toga-core==0.2.15
toga-django==0.2.15
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_dummy&subdirectory=src/dummy
-e git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_gtk&subdirectory=src/gtk
...

I have removed version numbers from my setup.py, see: 

https://github.com/jedie/RunCalculator/blob/pybee/setup.py

EDIT: I "revert" the venv changes and reinstall toga from sources and try to start the django server, i get ImportError: No module named 'toga.django'

see:

$ ./django/manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f045a9739d8>
Traceback (most recent call last):
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/jens/repos/RunCalculator-Env/lib/python3.5/site-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'toga.django'

@freakboy3742
Copy link
Member

The issue isn't with the Django template; the issue is with the environment in which you're running the code (you've got Toga 0.2.15, not 0.3.0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants