[英]Q: Python/Docker - No matching distribution found for Django==4.0.2 when running docker container
我有一個項目,我試圖在我的 Visual Studio 代碼編輯器中運行名為 Veganettest,但是,當我運行docker-compose up
我收到一個錯誤,上面寫着ERROR: No matching distribution found for Django==4.0.2
即使這樣分布確實存在。 I have tried various other solutions on here like installing the library using pip install Django
pip could not find a version that satisfies the requirement django==2.2.1 , Tried to downgrade and upgrade the version of Django to different values ex. Django==3.1.3、Django==3.0 和 Django==4.0 錯誤:找不到滿足 tensorflow 要求的版本(來自版本:無)錯誤:沒有為 tensorflow 找到匹配的分布)但是當我嘗試這些解決方案時他們不工作。 該錯誤來自我的 requirements.txt 文件,特別是來自聲明Django==4.0.2
作為要求的第一行。
這是我最初遇到的一些警告的完整錯誤:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B4E55BC430>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/django/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B4E55DE070>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/django/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B4E55DE220>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/django/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B4E55DE3D0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/django/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B4E55DE580>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/django/
ERROR: Could not find a version that satisfies the requirement Django==4.0.2 (from versions: none)
ERROR: No matching distribution found for Django==4.0.2
這里分別是我的 requirements.txt、Dockerfile、docker-compose.yml 和 manage.py 文件:
要求.txt:
Django==4.0.2
djangorestframework==3.12.2
mysqlclient==2.0.1
django-mysql==3.9
django-cors-headers==3.5.0
pika==1.1.0
pillow==9.0.0
matplotlib==3.5.0
Dockerfile:
FROM python:3.9
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
docker-compose.yml:
version: '3.9'
services:
backend:
build:
context: .
dockerfile: Dockerfile
command: 'python manage.py runserver 0.0.0.0:8000'
ports:
- 8000:8000
volumes:
- .:/app
depends_on:
- db
db:
image: mysql:5.7.22
restart: always
environment:
MYSQL_DATABASE: veganettest
MYSQL_USER: foodiehutts
MYSQL_PASSWORD: bobaboyheheh21342345><L
MYSQL_ROOT_PASSWORD: root
volumes:
- .dbdata:/var/lib/mysql
ports:
- 33065:3306
管理.py:
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'veganettest.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
為什么會發生此錯誤? 我能做些什么來解決它? 謝謝你。
I had a similar issue and upgrading pip worked for me ( RUN pip install --upgrade pip && pip install -r requirements.txt
). 不過,我沒有“NewConnectionError”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.