【问题标题】:Django doesn't find allauthDjango没有找到allauth
【发布时间】:2018-12-16 15:36:31
【问题描述】:

我有一个名为 manager 的项目的 venv。我在 venv 上安装了 allauth,但出现此错误:

ImportError: 没有名为“allauth”的模块

点冻结:

(manager) user@host:~/manager$ pip freeze
certifi==2018.11.29
chardet==3.0.4
defusedxml==0.5.0
Django==2.1.4
django-allauth==0.38.0
django-crispy-forms==1.7.2
idna==2.8
oauthlib==2.1.0
python3-openid==3.1.0
pytz==2018.7
requests==2.21.0
requests-oauthlib==1.0.0
urllib3==1.24.1
(manager) reiser@assets:~/manager$ pip freeze
certifi==2018.11.29
chardet==3.0.4
defusedxml==0.5.0
Django==2.1.4
django-allauth==0.38.0
django-crispy-forms==1.7.2
idna==2.8
oauthlib==2.1.0
python3-openid==3.1.0
pytz==2018.7
requests==2.21.0
requests-oauthlib==1.0.0
urllib3==1.24.1

settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'invoices',
    'feedback',
    'crispy_forms',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',

]

django 运行服务器错误:

user@host:~/manager/src$ python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7ff29b7c8d08>
Traceback (most recent call last):
  File "/home/reiser/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/reiser/.local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/reiser/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "/home/reiser/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/home/reiser/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/reiser/.local/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/reiser/.local/lib/python3.5/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/home/reiser/.local/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  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 'allauth'

在构建 venv 时使用的 Python 版本也是 3.5:

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.5   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.5   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 

我做错了什么?

我还必须提到,在重新启动计算机之前它可以正常工作。电脑是 Debian 9。

【问题讨论】:

  • 对我来说,您似乎忘记激活您的 venv。 (因为使用的 Django 似乎不在你的 venv 中。)它应该看起来像 (manager) user@host:~/manager/src$ python manage.py runserver

标签: python django python-venv


【解决方案1】:

这个错误意味着找不到模块。

您可能只需要在您的服务器上安装名为 allauth 的第 3 方模块(或将其添加到 requirements.txt)。

pip install django-allauth

您可以在本地运行 pip freeze 以查看安装了哪些模块。

要安装特定版本的 django-allauth,请使用:

pip install django-allauth==0.32.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 2021-09-04
    • 2016-10-20
    • 1970-01-01
    • 2016-11-21
    • 2012-01-16
    相关资源
    最近更新 更多