Lokicor
Lokicor

Reputation: 137

ERROR RUN pip install -r requirements.txt when using docker-compose up

How should I create and install the requirements.txt file in order to be able to read it properly when running docker-compose up?

Problems when running docker-compose up with the requirements.txt created via pip freeze > requirements.txt

requirements.txt:

certifi==2021.5.30
charset-normalizer==2.0.3
Django==2.2.5
django-cors-headers==3.7.0
django-rest-framework==0.1.0
djangorestframework==3.12.4
idna==3.2
psycopg2 @ file:///C:/ci/psycopg2_1612298715048/work
python-decouple==3.4
pytz @ file:///tmp/build/80754af9/pytz_1612215392582/work
requests==2.26.0
sqlparse @ file:///tmp/build/80754af9/sqlparse_1602184451250/work
urllib3==1.26.6
wincertstore==0.2

I use anaconda and pip to install packages

The Dockerfile for the backend of my app tries to RUN pip install -r requirements.txt rising the following errors. I could sense the @ packages arise error, but the strangest for me is the first one (#17 1.299) since it seems to be focusing on python-decouple==3.4 as just python.

=> ERROR [... 4/5] RUN pip install -r requirements.txt                                 1.8s 
------
> [... 4/5] RUN pip install -r requirements.txt:
#17 1.299 DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
#17 1.345 Collecting certifi==2021.5.30 (from -r requirements.txt (line 1))
#17 1.515 Collecting charset-normalizer==2.0.3 (from -r requirements.txt (line 2))
#17 1.541   Could not find a version that satisfies the requirement charset-normalizer==2.0.3 (from -r requirements.txt (line 2)) (from versions: 0.1a0, 0.1.1a0, 0.1.4b0, 0.1.5b0, 0.1.7, 0.1.8, 0.2.0, 0.2.1, 0.2.2, 0.2.3)
#17 1.544 No matching distribution found for charset-normalizer==2.0.3 (from -r requirements.txt (line 2))
#17 1.708 You are using pip version 19.0.3, however version 19.1.1 is available.
#17 1.708 You should consider upgrading via the 'pip install --upgrade pip' command.```

Upvotes: 1

Views: 6096

Answers (1)

Nitheesh Chandra
Nitheesh Chandra

Reputation: 21

TL;DR

Replace charset-normalizer==2.0.3 with chardet>=3.0.2,<5; in requirements.txt. You can choose some specific version to lock version in place aswell.


I had to set up an old repo recently, faced a similar issue

charset-normalizer was installed by requests which are no longer possible, yet to explore why/how it worked before!

But if you check the requirements of requests==2.26.0 psf/requests:v2.26.0::seup.py

For Python version less than 3 we have to install chardet>=3.0.2,<5; insterd of charset_normalizer~=2.0.0

Errors messages are always helpful, at the least to identify issues origin

Upvotes: 2

Related Questions