ModuleNotFoundError: No module named 'django_countries'

ModuleNotFoundError: No module named 'django_countries'

我有一个 docker django 项目,我想使用 django-countries。

这是我的requirements.txt

....
django-countries
django-cities

这是 settings.py 文件中的 INSTALLED_APPS

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_countries',
    ... (others)
]

当我 运行 docker-up 时,我收到以下错误:

docker_name  | Traceback (most recent call last):
docker_name  |   File "/app/manage.py", line 22, in <module>
docker_name  |     main()
docker_name  |   File "/app/manage.py", line 18, in main
docker_name  |     execute_from_command_line(sys.argv)
docker_name  |   File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
docker_name  |     utility.execute()
docker_name  |   File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 377, in execute
docker_name  |     django.setup()
docker_name  |   File "/usr/local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
docker_name  |     apps.populate(settings.INSTALLED_APPS)
docker_name  |   File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
docker_name  |     app_config = AppConfig.create(entry)
docker_name  |   File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 90, in create
docker_name  |     module = import_module(entry)
docker_name  |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
docker_name  |     return _bootstrap._gcd_import(name[level:], package, level)
docker_name  |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
docker_name  |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
docker_name  |   File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
docker_name  | ModuleNotFoundError: No module named 'django_countries'

有什么想法吗?

pip 安装 django-countries-with-calling-codes