ImportError for SimpleJWTAuthMixin in example project
sillyapplemuffin opened this issue · 4 comments
I tried your example to understand how it work but when running >python .\manage.py migrate
or runserver
with example project, their is an import error for SimpleJWTAuthMixin.
Traceback (most recent call last):
File ".\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python37\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python37\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Python37\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Python37\lib\site-packages\django\core\management\commands\migrate.py", line 60, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "C:\Python37\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Python37\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Python37\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Python37\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Python37\lib\site-packages\django\urls\resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "C:\Python37\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python37\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python37\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python37\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Python37\lib\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 "C:\Python Test\django-rest-social-auth\example_project\config\urls.py", line 5, in <module>
from users import views
File "C:\Python Test\django-rest-social-auth\example_project\users\views.py", line 11, in <module>
from rest_social_auth.views import JWTAuthMixin, KnoxAuthMixin, SimpleJWTAuthMixin
ImportError: cannot import name 'SimpleJWTAuthMixin' from 'rest_social_auth.views' (C:\Python37\lib\site-packages\rest_social_auth\views.py)
I put all the trace in case it's needed.
Using an older commit, i got the example working as it migth only come from the last rename commit.
Thank you. :)
Hey @sillyapplemuffin !
Are you sure your rest_social_auth
is up to date (i.e. it is from master branch and from official pypi)?
These changes are not deployed to pypi yet.
To be sure that you use rest_social_auth package from current repo, you can specify PYTHONPATH
explicitly, as written in the readme:
PYTHONPATH='../' python manage.py migrate
PYTHONPATH='../' python manage.py runserver
Ok then, my mistake !
I guess i've miss something out.
I'm not very good so this might be obvious, but using PYTHONPATH
overwrite the 'normal' python install of rest_social_auth package so everything is on the same version ?
Thank you very much for your time and sorry for the disturbance.
@sillyapplemuffin
Python will check PYTHONPATH first to find the package, before searching the standard path, check the docs:
https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH
I'm closing this since can't reproduce (looks like a version mismatch issue).
If it appears again - please re-open.