ModuleNotFoundError:没有名为“ widget_tweaks”的模块

时间:2018-08-24 06:48:34

标签: python django docker-compose

我正在使用docker和django(2.1)编写项目。 我已经在容器内安装了模块“ django-widget-tweaks”,并将“ widget_tweaks”添加到INSTALLED_APPS中。当我使用docker-compose up启动项目时,一切正常,但是当我想在另一个终端中运行类似docker-compose run <container name> python manage.py test的东西时,会发生错误。

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 90, 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 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'widget_tweaks'

但是当我在Docker容器中直接运行相同的命令python manage.py test时,它就可以工作。 widget-tweaks已安装在容器和我的机器上。您能提出一些解决问题的建议吗?

谢谢!

0 个答案:

没有答案