django app中没有名为jsoneditor的模块错误

时间:2017-08-31 12:07:46

标签: django python-3.x django-models

这是错误:

    /app$ python3 manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
    django.setup()
  File "/python/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/python/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/python/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'jsoneditor'

但实际上我安装了jsoneditor

pip3 install django-jsoneditor
Requirement already satisfied: django-jsoneditor in/usr/local/lib/python3.5/dist-packages
Requirement already satisfied: packaging in /usr/local/lib/python3.5/dist-packages (from django-jsoneditor)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from packaging->django-jsoneditor)
Requirement already satisfied: pyparsing in /usr/lib/python3/dist-packages (from packaging->django-jsoneditor)

我已安装的应用

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'jsoneditor'
    ]

然后为什么会出现这个错误? 怎么了?

1 个答案:

答案 0 :(得分:0)

这种错误发生在2例中,

1)INSTALLED_APPS:

请确保您的模块位于Installed_Apps下方, 你需要在使用前定义。

INSTALLED_APPS = (
    'jsoneditor',
)

2)Virtualenv:

如果你是virtualenv,你应该确保你的包裹使用,

pip freeze

如果没有,请在virtualenv下安装,

source bin/activate

然后pip install django-jsoneditor

如果您全局安装并尝试在virtulenv下导入它将无法正常工作。

所以尝试它应该工作