Python Env Piptools

Posted by Zhenda on Mon, Aug 25, 2025
Total Views:

简易的, 适合python包管理工具

pip-tools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
pip install pip-tools

pip-compile requirements.in
# 会删除多余包, 包严格一致
pip-sync requirements.txt




# 更新依赖包 requirements.txt
pip-compile --upgrade
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
FROM python:3.11-slim

WORKDIR /app
COPY requirements.in .
RUN pip install pip-tools \
    && pip-compile requirements.in \
    && pip-sync requirements.txt

COPY . .

CMD ["python", "main.py"]

pipdeptree

1
2
3
pip install pipdeptree
# pipdeptree 默认是分析当前环境里的包
pipdeptree