Postgresql

錯誤:無法從“11.7”確定 PostgreSQL 版本

  • May 15, 2021

我找到了一個 Django 項目,但未能通過以下方式在 Docker 容器中執行:

  1. 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

我錯過了什麼?

先感謝您

錯誤:無法從“11.7”確定 PostgreSQL 版本

的已知錯誤psycopg2<=2.6.2嘗試通過編輯它requirements.txt並更改psycopg2==2.6.0psycopg2==2.7.

引用自:https://serverfault.com/questions/1063607