我正在使用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已安装在容器和我的机器上。您能提出一些解决问题的建议吗?
谢谢!