平时在mac上开发,但是部署却在linux中,这就造成两边的依赖包系统不兼容的问题,所以需要将其下载成对应操作系统的包,然后离线安装。

导出Python项目的依赖

1
pip freeze >requirements.txt

下载依赖包

1
pip download -d dept -r requirements.txt --only-binary=:all: --platform linux_x86_64 -i https://pypi.tuna.tsinghua.edu.cn/simple

如果个别依赖包不支持二进制的,那么就把--only-binary=:all:替换为--no-deps

安装依赖包

1
pip install --no-index --find-links= dept/ -r requirements.txt