ModuleNotFoundError: No module named 'django_countries'

5.8k views Asked by At

I have a docker django project and I want to use django-countries.

This is my requirements.txt

....
django-countries
django-cities

This is the INSTALLED_APPS in settings.py file

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)
]

When I run docker-up, I receive the below error:

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'

Any ideas?

1

There are 1 answers

1
Abdelfattah M. Abdelrahmen On BEST ANSWER

pip install django-countries-with-calling-codes