Search code examples
djangodockerpipdocker-composedjango-debug-toolbar

Django uninstalled after installing django-debug-toolbar in docker container, how to install it without un installing django?


I was trying to install django debug toolbar in my container using

[shub@debian teamwave](task-details-api)$ docker exec -it teamwave_backend_1 pip install django-debug-toolbar Collecting django-debug-toolbar   Downloading https://files.pythonhosted.org/packages/01/9a/3db232bd15882d90d3c53de1f34ce0a522327849593c9198899713267cfe/django_debug_toolbar-1.11-py2.py3-none-any.whl (201kB)
    100% |████████████████████████████████| 204kB 426kB/s  Collecting sqlparse>=0.2.0 (from django-debug-toolbar)   Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl Collecting Django>=1.11 (from django-debug-toolbar)   Downloading https://files.pythonhosted.org/packages/61/cb/e3c6bfccdf23c48dd4ce014b96178aa048b9450739eaa5f11d4d23d9d5d6/Django-1.11.23-py2.py3-none-any.whl (6.9MB)
    100% |████████████████████████████████| 7.0MB 544kB/s  Requirement already satisfied: pytz in /usr/local/lib/python2.7/site-packages (from Django>=1.11->django-debug-toolbar) (2015.2) Installing collected packages: sqlparse, Django, django-debug-toolbar   Found existing installation: sqlparse 0.1.15
    Uninstalling sqlparse-0.1.15:
      Successfully uninstalled sqlparse-0.1.15   Found existing installation: Django 1.8.18
    Uninstalling Django-1.8.18:

I have tried running the container and installing the django

Starting teamwave_backend_1 ... done Attaching to teamwave_backend_1

backend_1  | Traceback (most recent call last):
backend_1  |   File "manage.py", line 8, in <module>
backend_1  |     from django.core.management import execute_from_command_line
backend_1  | ImportError: No module named django.core.management
teamwave_backend_1 exited with code 1

I later fixed my django by docker-compose build but I want django-debug-toolbar too.

This is my docker-compose.yml

version: '3'

services:
  db:
    image: postgres:10-alpine
    environment:
      - POSTGRES_PASSWORD=dsdbadmin
      - POSTGRES_DB=tm_v1.1
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
  backend:
    build: .
    volumes:
      - .:/backend
    ports:
      - "8000:8000"
    depends_on:
      - db
      - redis
  redis:
    image: redis:4-alpine

volumes:
  pgdata:

And this is my Dockerfile

FROM python:2
ENV PYTHONUNBUFFERED 1
WORKDIR /backend
ADD req.txt /backend/
RUN pip install --upgrade pip
RUN pip install -r req.txt
ADD . /backend/

ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"]

EXPOSE 8000

I use docker-compose up to run my containers


Solution

  • installing the latest version from django-debug-toolbar will install Django-1.11.23 and uninstall older Django versions .

    you may try to find the correct django-debug-toolbar for Django-1.8