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

ImportError fix #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

ImportError fix #39

wants to merge 1 commit into from

Conversation

boburxon
Copy link

@boburxon boburxon commented Feb 3, 2022

Removed unused smart_text import from the authentication.py. This line causes ImportError on Django 4.0

Removed unused `smart_text`
@ghost
Copy link

ghost commented Feb 11, 2022

Has there been any update on this issue? I am also stuck on the same issue:

(proj-env) user01@apu proj % python3 manage.py migrate drf_firebase_auth
Traceback (most recent call last):
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/settings.py", line 177, in import_from_string
    return import_string(val)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/proj/proj-env/lib/python3.9/site-packages/drf_firebase_auth/authentication.py", line 11, in <module>
    from django.utils.encoding import smart_text
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/var/proj/proj-env/lib/python3.9/site-packages/django/utils/encoding.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/proj/manage.py", line 21, in <module>
    main()
  File "/var/proj/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/base.py", line 90, in wrapped
    res = handle_func(*args, **kwargs)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 75, in handle
    self.check(databases=[database])
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/management/base.py", line 438, in check
    all_issues = checks.run_checks(
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/checks/registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/urls/resolvers.py", line 446, in check
    for pattern in self.url_patterns:
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/urls/resolvers.py", line 632, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/var/proj/proj-env/lib/python3.9/site-packages/django/urls/resolvers.py", line 625, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/proj/proj/urls.py", line 1, in <module>
    from builder.views import GenerateFlavorAndUpload, VerifyImageAccess, VerifyPortalName, RunJob, \
  File "/var/proj/builder/views.py", line 10, in <module>
    from rest_framework.views import APIView
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/views.py", line 17, in <module>
    from rest_framework.schemas import DefaultSchema
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/schemas/__init__.py", line 33, in <module>
    authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/settings.py", line 225, in __getattr__
    val = perform_import(val, attr)
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/settings.py", line 168, in perform_import
    return [import_from_string(item, setting_name) for item in val]
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/settings.py", line 168, in <listcomp>
    return [import_from_string(item, setting_name) for item in val]
  File "/var/proj/proj-env/lib/python3.9/site-packages/rest_framework/settings.py", line 180, in import_from_string
    raise ImportError(msg)
ImportError: Could not import 'drf_firebase_auth.authentication.FirebaseAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/var/proj/proj-env/lib/python3.9/site-packages/django/utils/encoding.py).

@boburxon
Copy link
Author

Deleting the unused import will resolve the issue, you can fork the repo and use it in your requirements.txt to install fixed version

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

Successfully merging this pull request may close these issues.

1 participant