![错误:无法从‘11.7’确定 PostgreSQL 版本](https://linux22.com/image/766636/%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E4%BB%8E%E2%80%9811.7%E2%80%99%E7%A1%AE%E5%AE%9A%20PostgreSQL%20%E7%89%88%E6%9C%AC.png)
我找到了一个Django项目,但无法通过以下方式在Docker容器中运行它:
git clone https://github.com/hotdogee/django-blast.git
我有以下 Dockerfile:
FROM python:2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
对于docker-compose.yml
我来说:
version: "3"
services:
db:
image: postgres
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
接下来,我遇到了这个错误:
$ docker-compose build
...
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info
cwd: /tmp/pip-install-Gq_JSR/psycopg2/
Complete output (7 lines):
running egg_info
creating /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info
writing /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file '/tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: could not determine PostgreSQL version from '11.7'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.0.2; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
我错过了什么?
先感谢您
答案1
错误:无法从‘11.7’确定 PostgreSQL 版本
已知漏洞尝试psycopg2<=2.6.2
通过编辑其requirements.txt
并更改psycopg2==2.6.0
为psycopg2==2.7
。