未安装Django INSTALLED_APPS并阻止makemigrations

时间:2016-09-10 17:28:16

标签: python django django-models pip

我最近从GitHub中取出了一个回购,以便在我的机器上获得本地副本。后端使用Django,我正在努力更新一些模型。由于我改变了一些模型,我想运行./manage.py makemigrations。起初python2与python3存在问题,因此我将#!/usr/bin/env python更改为#!/usr/bin/env python3。然后,当我运行makemigrations时,我明白了:

  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/Library/Frameworks/Python.framework/Versions/3.5/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 'autofixture'

进一步了解,我发现这是因为我的settings.py文件在autofixture中有bootstrap3formtoolsINSTALLED_APPS,但不知何故我的机器没有这些。我已尝试pip install所有这些,但名称autofixture,bootstrap3和formtools在pip中找不到。

1 个答案:

答案 0 :(得分:1)

他们虽然不是那些名字,但他们都在p ;;它们分别是django-autofixturedjango-bootstrap3django-formtools

所以你可以输入:

来安装它们
pip install django-autofixture django-bootstrap3 django-formtools

修改:使用python3时使用pip3代替pip

 pip3 install django-autofixture django-bootstrap3 django-formtools