如何下载离线跨平台特定 Python 版本依赖的 Python 包?

如何下载离线跨平台特定 Python 版本依赖的 Python 包?

我有一台装有 Python 3.10.10 和 pip 23.0.1 的在线 Windows PC。我想为装有 64 位 Linux 和 Python 3.6.8 的离线计算机下载一个 Python 包及其依赖项。我试过:

pip download --platform=linux_x86_64 --only-binary=:all: --python-version=3.6.8 podman-compose

实际结果

Collecting podman-compose
  Using cached podman_compose-1.0.3-py2.py3-none-any.whl (27 kB)
Collecting python-dotenv
  Using cached python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Collecting podman-compose
  Using cached podman_compose-1.0.2-py2.py3-none-any.whl (27 kB)
  Using cached podman_compose-0.1.11-py2.py3-none-any.whl (28 kB)
  Using cached podman_compose-0.1.10-py2.py3-none-any.whl (28 kB)
  Using cached podman_compose-0.1.9-py2.py3-none-any.whl (27 kB)
  Using cached podman_compose-0.1.8-py2.py3-none-any.whl (27 kB)
  Using cached podman_compose-0.1.5-py2.py3-none-any.whl (20 kB)
  Using cached podman_compose-0.1.4-py2.py3-none-any.whl (20 kB)
  Using cached podman_compose-0.1.3-py2.py3-none-any.whl (20 kB)
ERROR: Cannot install podman-compose==0.1.10, podman-compose==0.1.11, podman-compose==0.1.3, podman-compose==0.1.4, podman-compose==0.1.5, podman-compose==0.1.8, podman-compose==0.1.9, podman-compose==1.0.2 and podman-compose==1.0.3 because these package versions have conflicting dependencies.

The conflict is caused by:
    podman-compose 1.0.3 depends on pyyaml
    podman-compose 1.0.2 depends on pyyaml
    podman-compose 0.1.11 depends on pyyaml
    podman-compose 0.1.10 depends on pyyaml
    podman-compose 0.1.9 depends on pyyaml
    podman-compose 0.1.8 depends on pyyaml
    podman-compose 0.1.5 depends on pyyaml
    podman-compose 0.1.4 depends on pyyaml
    podman-compose 0.1.3 depends on pyyaml

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

我不完全明白这里发生了什么,但看起来它试图获取所有可能的软件包版本但失败了,因为它们都需要不同的依赖版本。

预期结果

上述命令应该寻找podman-compose所有依赖项均可与 Python 3.6.8 兼容的最新版本。

我究竟做错了什么?

答案1

由于我没有指定特定的软件包版本,所以我想知道这里的限制是否太严格,因此pip无法解决依赖关系。我最终通过将平台从更改为来使其正常linux_x86_64工作manylinux1_x86_64

pip download --platform=manylinux1_x86_64 --only-binary=:all: --python-version=3.6.8 podman-compose

为了在目标系统上安装该软件包,我将下载的文件复制到其中并通过以下方式安装它们:

pip install --no-index --find-links /path/to/pip/files podman-compose

相关内容