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

Incorrect installation order of rosetta and django-rosetta causes ImportError. #224

Open
rhbvkleef opened this issue Jun 11, 2019 · 2 comments

Comments

@rhbvkleef
Copy link

With the danger of duplicating #209, I would like to report an issue w.r.t. the installation order of the rosetta and django-rosetta packages. When rosetta is installed after django-rosetta, rosetta overrides the rosetta/__init__.py of django-rosetta, causing an ImportError on the get_version function in Django. Pipenv regularly installs rosetta and django-rosetta in the wrong order.

  • django version: 2.1.9
  • django-rosetta version: 0.9.3
  • python version: 3.7.3
  • pipenv version: 2018.11.15.dev0

Stacktrace

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
    super().run_from_argv(argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 56, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 605, in run_tests
    self.run_checks()
  File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 567, in run_checks
    call_command('check', verbosity=self.verbosity)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/check.py", line 65, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 366, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/builds/www/steambird/steambird/urls.py", line 31, in <module>
    path('translations/', include('rosetta.urls'))
  File "/usr/local/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.7/site-packages/rosetta/urls.py", line 5, in <module>
    from . import views
  File "/usr/local/lib/python3.7/site-packages/rosetta/views.py", line 32, in <module>
    from . import get_version as get_rosetta_version
ImportError: cannot import name 'get_version' from 'rosetta' (/usr/local/lib/python3.7/site-packages/rosetta/__init__.py)
@mbi
Copy link
Owner

mbi commented Jun 12, 2019

Thank you for reporting this… but I'm not sure I understand. Under which circumstances are you going to install both django-rosetta and rosetta? I.e. the "normal" use case is to install the former via e.g. pip install django-rosetta, how / when would you want to install rosetta directly?

Thanks.

@jayvdb
Copy link

jayvdb commented Apr 13, 2020

While not as old, https://pypi.org/project/rosetta/#history says it has been installable via pip since 2013. https://pypistats.org/packages/rosetta shows it isnt a highly used package, but no doubt there is a valid use-case with django, and thus with django-rosetta.

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

No branches or pull requests

3 participants