i have 2 similar projects(FastAPI, redis, postgres) with same Dockerfile:
FROM python:3.14.2-slim
WORKDIR /myapp
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV PYTHONPATH=/myapp
First one works well, but second crashes with(API):
ImportError: cannot import name 'AskError' from 'redis.exceptions' (/usr/local/lib/python3.14/site-packages/redis/exceptions.py).
I know the cause, for some reason: there is redis 2.0.0 in site-packages folder(in working project everyrhing is fine and it's actually 7.1.0 version), but in both projects there is:
redis==7.1.0
I tried:
enter the docker container and run:
pip show redis(it says7.1.0version)then I went to
/usr/local/lib/python3.14/site-packages/redis/and i see in__init__.pythe line__version__ = 2.0.0(WHY!?!?!).Obviously the
exceptions.pyfile does not haveAskErrorexception classAlso i tried to put this in dockerfile:
FROM python:3.14.2-slim
WORKDIR /myapp
RUN pip install --upgrade pip && \
pip uninstall -y redis && \
rm -rf /usr/local/lib/python*/site-packages/redis*
. . .
requirements.txt
aiofiles==25.1.0
aiogram==3.24.0
aiogram-dependency==1.1.0
aiohappyeyeballs==2.6.1
aiohttp==3.13.3
aiosignal==1.4.0
alembic==1.18.1
amqp==5.3.1
annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.12.1
asgiref==3.11.0
asyncpg==0.31.0
attrs==25.4.0
bcrypt==5.0.0
billiard==4.2.4
Booktype==1.5
celery==5.6.2
certifi==2026.1.4
click==8.3.1
click-didyoumean==0.3.1
click-plugins==1.1.1.2
click-repl==0.3.0
colorama==0.4.6
contourpy==1.3.3
cycler==0.12.1
Django==6.0.1
fastapi==0.128.0
fonttools==4.61.1
frozenlist==1.8.0
greenlet==3.3.0
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.11
iniconfig==2.3.0
kiwisolver==1.4.9
kombu==5.6.2
magic-filter==1.0.12
Mako==1.3.10
MarkupSafe==3.0.3
matplotlib==3.10.8
multidict==6.7.0
numpy==2.4.2
packaging==25.0
pandas==3.0.0
pillow==12.1.1
pluggy==1.6.0
prompt_toolkit==3.0.52
propcache==0.4.1
pydantic==2.12.5
pydantic-settings==2.12.0
pydantic_core==2.41.5
Pygments==2.19.2
PyJWT==2.10.1
pyparsing==3.3.2
pytest==9.0.2
pytest-asyncio==1.3.0
pytest-env==1.2.0
python-dateutil==2.9.0.post0
python-dotenv==1.2.1
python-multipart==0.0.21
redis==7.1.0
setuptools==80.9.0
simplejson==3.20.2
six==1.17.0
SQLAlchemy==2.0.45
sqlparse==0.5.5
starlette==0.50.0
typing-inspection==0.4.2
typing_extensions==4.15.0
tzdata==2025.3
tzlocal==5.3.1
uvicorn==0.40.0
vine==5.1.0
wcwidth==0.2.14
yarl==1.22.0