解决docker安装pip问题

This commit is contained in:
2025-11-24 13:19:29 +08:00
parent d02d537330
commit c402b6097f

View File

@@ -29,7 +29,8 @@ COPY schoolNewsCrawler/ /app/crawler/
RUN cd /app/crawler && \ RUN cd /app/crawler && \
if [ -f requirements.txt ]; then \ if [ -f requirements.txt ]; then \
echo "安装爬虫依赖..."; \ echo "安装爬虫依赖..."; \
python3 -m pip install --no-cache-dir -r requirements.txt; \ # Python 3.12 引入了 PEP 668 规范,默认禁止在系统环境直接使用 pip 安装包,防止破坏系统 Python 环境。
python3 -m pip install --no-cache-dir --break-system-packages -r requirements.txt; \
else \ else \
echo "警告: 未找到requirements.txt文件"; \ echo "警告: 未找到requirements.txt文件"; \
fi fi