找不到满足 psycopg2 要求的版本
Could not find a version that satisfies the requirement psycopg2
我正在为我的 Python + Django 项目开发 CI。我必须使用 python:3.9-alpine
图像。我的 CI 管道中出现了一个奇怪的错误:
WARNING: Discarding https://files.pythonhosted.org/packages/aa/8a/7c80e7e44fb1b4277e89bd9ca509aefdd4dd1b2c547c6f293afe9f7ffd04/psycopg2-2.9.1.tar.gz#sha256=de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement psycopg2==2.9.1 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2)
Preparing metadata (setup.py): finished with status 'error'
ERROR: No matching distribution found for psycopg2==2.9.1
我在可用版本列表中看到 2.9.1
我的.gitlab-ci.yml
stages:
- linter
- build_pip
- build
- meta
- code_quality
- deploy
.except-tags:
except:
- tags
build_pip:build_dist:
stage: build_pip
# image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.9-alpine
image: python:3.9-alpine
variables:
OPENCV_VERSION: "4.5.3.56"
before_script:
- pip install --upgrade pip setuptools wheel
- apk update apk add -q --update --no-cache
- postgresql-dev musl-dev
...
- pip install -r requirements/production.txt --no-cache
script:
- python setup.py bdist_wheel
- echo PIP_CI_JOB_ID=$CI_JOB_ID > PIP_CI_JOB_ID.env
dependencies: []
artifacts:
expire_in: 1 hour
paths:
- dist/
- version
reports:
dotenv: PIP_CI_JOB_ID.env
extends:
- .except-tags
...
requirements/production.txt
djangorestframework==3.12.4
drf-extra-fields==3.1.1
djangorestframework-camel-case==1.2.0 # https://pypi.org/project/djangorestframework-camel-case/
Pillow==8.3.2
python-dateutil==2.8.2 # datetime formatting
psycopg2==2.9.1
opencv-python==4.5.3.56
drf-yasg==1.20.0
sentry-sdk==1.4.3
gunicorn==20.1.0
requests==2.26.0
yarl==1.7.0
googlemaps==4.5.3
django_redis==5.0.0
celery==5.2.0
channels==3.0.4
channels_redis==3.3.1
完整的 gitlab ci 日志:https://pastebin.com/QhMhErF7
这个错误的原因是什么?
我试图用 psycopg2-binary
替换 psycopg2
但出现了同样的错误。
What is the reason of my error?
您是否读过 您的类似问题?最后一部分警告 Alpine + Python 的某些组合,这似乎正在发生。
I tried to replace psycopg2 with psycopg2-binary but have the same error
这里的问题可能是 python 库依赖于 gcc
,默认情况下不在 alpine 上提供。
尝试替换这个:
before_script:
- pip install --upgrade pip setuptools wheel
- apk update
- apk add -q --update --no-cache postgresql-dev musl-dev
与:
before_script:
- pip install --upgrade pip setuptools wheel
- apk update
- apk add -q --no-cache postgresql-dev gcc python3-dev musl-dev
请注意,添加 gcc
会增加图像大小,因为这可能是 psycopg2
或 psycopg2-binary
的依赖项。如果图像大小增长很多,我认为坚持使用 alpine 没有意义,您可以通过切换到基于 debian 的图像来避免更多 Python 头痛。
我正在为我的 Python + Django 项目开发 CI。我必须使用 python:3.9-alpine
图像。我的 CI 管道中出现了一个奇怪的错误:
WARNING: Discarding https://files.pythonhosted.org/packages/aa/8a/7c80e7e44fb1b4277e89bd9ca509aefdd4dd1b2c547c6f293afe9f7ffd04/psycopg2-2.9.1.tar.gz#sha256=de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement psycopg2==2.9.1 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2)
Preparing metadata (setup.py): finished with status 'error'
ERROR: No matching distribution found for psycopg2==2.9.1
我在可用版本列表中看到 2.9.1
我的.gitlab-ci.yml
stages:
- linter
- build_pip
- build
- meta
- code_quality
- deploy
.except-tags:
except:
- tags
build_pip:build_dist:
stage: build_pip
# image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.9-alpine
image: python:3.9-alpine
variables:
OPENCV_VERSION: "4.5.3.56"
before_script:
- pip install --upgrade pip setuptools wheel
- apk update apk add -q --update --no-cache
- postgresql-dev musl-dev
...
- pip install -r requirements/production.txt --no-cache
script:
- python setup.py bdist_wheel
- echo PIP_CI_JOB_ID=$CI_JOB_ID > PIP_CI_JOB_ID.env
dependencies: []
artifacts:
expire_in: 1 hour
paths:
- dist/
- version
reports:
dotenv: PIP_CI_JOB_ID.env
extends:
- .except-tags
...
requirements/production.txt
djangorestframework==3.12.4
drf-extra-fields==3.1.1
djangorestframework-camel-case==1.2.0 # https://pypi.org/project/djangorestframework-camel-case/
Pillow==8.3.2
python-dateutil==2.8.2 # datetime formatting
psycopg2==2.9.1
opencv-python==4.5.3.56
drf-yasg==1.20.0
sentry-sdk==1.4.3
gunicorn==20.1.0
requests==2.26.0
yarl==1.7.0
googlemaps==4.5.3
django_redis==5.0.0
celery==5.2.0
channels==3.0.4
channels_redis==3.3.1
完整的 gitlab ci 日志:https://pastebin.com/QhMhErF7
这个错误的原因是什么?
我试图用 psycopg2-binary
替换 psycopg2
但出现了同样的错误。
What is the reason of my error?
您是否读过
I tried to replace psycopg2 with psycopg2-binary but have the same error
这里的问题可能是 python 库依赖于 gcc
,默认情况下不在 alpine 上提供。
尝试替换这个:
before_script:
- pip install --upgrade pip setuptools wheel
- apk update
- apk add -q --update --no-cache postgresql-dev musl-dev
与:
before_script:
- pip install --upgrade pip setuptools wheel
- apk update
- apk add -q --no-cache postgresql-dev gcc python3-dev musl-dev
请注意,添加 gcc
会增加图像大小,因为这可能是 psycopg2
或 psycopg2-binary
的依赖项。如果图像大小增长很多,我认为坚持使用 alpine 没有意义,您可以通过切换到基于 debian 的图像来避免更多 Python 头痛。