ImportError:无法导入名称' NAMESPACE'

时间:2017-04-26 07:38:00

标签: python django heroku

我已经搜遍了所有的解决方案,但我找不到一个我得到的错误。我正在尝试迁移到heroku,每次运行命令时都会出错。

Traceback (most recent call last):   File "manage.py", line 22, in
<module>
    execute_from_command_line(sys.argv)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py",
line 367, in execute_from_command_line
    utility.execute()   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py",
line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py",
line 305, in run_from_argv
    self.execute(*args, **cmd_options)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py",
line 353, in execute
    self.check()   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py",
line 385, in check
    include_deployment_checks=include_deployment_checks,   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/commands/migrate.py",
line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py",
line 372, in _run_checks
    return checks.run_checks(**kwargs)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/checks/registry.py",
line 81, in run_checks
    new_errors = check(app_configs=app_configs)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/checks/urls.py",
line 14, in check_url_config
    return check_resolver(resolver)   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/checks/urls.py",
line 24, in check_resolver
    for pattern in resolver.url_patterns:   File "/app/.heroku/python/lib/python3.5/site-packages/django/utils/functional.py",
line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)   File "/app/.heroku/python/lib/python3.5/site-packages/django/urls/resolvers.py",
line 310, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)   File
"/app/.heroku/python/lib/python3.5/site-packages/django/utils/functional.py",
line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)   File "/app/.heroku/python/lib/python3.5/site-packages/django/urls/resolvers.py",
line 303, in urlconf_module
    return import_module(self.urlconf_name)   File "/app/.heroku/python/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 "/app/aroomie/urls.py", line 31, in <module>
    url(r'^api/social/', include('rest_framework_social_oauth2.urls')),   File
"/app/.heroku/python/lib/python3.5/site-packages/django/conf/urls/__init__.py",
line 50, in include
    urlconf_module = import_module(urlconf_module)   File "/app/.heroku/python/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 "/app/.heroku/python/lib/python3.5/site-packages/rest_framework_social_oauth2/urls.py",
line 6, in <module>
    from .views import ConvertTokenView, invalidate_sessions   File "/app/.heroku/python/lib/python3.5/site-packages/rest_framework_social_oauth2/views.py",
line 16, in <module>
    from .oauth2_endpoints import SocialTokenServer   File "/app/.heroku/python/lib/python3.5/site-packages/rest_framework_social_oauth2/oauth2_endpoints.py",
line 12, in <module>
    from .oauth2_grants import SocialTokenGrant   File "/app/.heroku/python/lib/python3.5/site-packages/rest_framework_social_oauth2/oauth2_grants.py",
line 12, in <module>
    from social.apps.django_app.views import NAMESPACE 
ImportError: cannot import name 'NAMESPACE'

我不知道从哪里开始或寻找问题。我会很感激任何方向。

谢谢

1 个答案:

答案 0 :(得分:0)

这似乎是库版本不兼容的问题。您需要确保您的social-auth-app-django和django-rest-framework-social-oauth2版本兼容。我能够成功地使用这两个:

django-rest-framework-social-oauth2==1.0.5
social-auth-app-django==1.1.0