在 docker 容器中安装 django-debug-toolbar 后卸载了 Django,如何在不卸载 django 的情况下安装它?
Django uninstalled after installing django-debug-toolbar in docker container, how to install it without un installing django?
我正在尝试使用
在我的容器中安装 Django 调试工具栏
[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:
我已经尝试 运行安装容器并安装 django
开始 teamwave_backend_1 ... 完成
附加到 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
我后来通过 docker-compose build
修复了我的 django,但我也想要 django-debug-toolbar。
这是我的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:
这是我的 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
我使用 docker-compose up
来 运行 我的容器
从 django-debug-toolbar
安装最新版本将安装 Django-1.11.23
并卸载旧的 Django 版本。
您可以尝试为 Django-1.8
找到正确的 django-debug-toolbar
我正在尝试使用
在我的容器中安装 Django 调试工具栏[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:
我已经尝试 运行安装容器并安装 django
开始 teamwave_backend_1 ... 完成 附加到 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
我后来通过 docker-compose build
修复了我的 django,但我也想要 django-debug-toolbar。
这是我的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:
这是我的 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
我使用 docker-compose up
来 运行 我的容器
从 django-debug-toolbar
安装最新版本将安装 Django-1.11.23
并卸载旧的 Django 版本。
您可以尝试为 Django-1.8
django-debug-toolbar