Pip Commonly Used
配置镜像
清华源
# for temp use
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple {package}
# set as default
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
私有源
假设我的私有源地址为: https://pypi.xxx.com/simple
永久配置:
pip config set global.extra-index-url https://pypi.xxx.com/simple
pip config set global.trusted-host pypi.xxx.com
Pip Install
在 A 平台下载/安装 B 平台的包 (Other Platforms)
平台选项:
- linux
- manylinux1_x86_64
- manylinux_2_12_i686
- manylinux_2_12_x86_64
- manylinux_2_17_aarch64
- manylinux_2_17_x86_64
- manylinux2010_i686
- manylinux2010_x86_64
- manylinux2014_aarch64
- manylinux2014_s390x
- manylinux2014_x86_64
- macos
- macosx_10_9_x86_64
- macosx_10_9_universal2
- macosx_10_14_x86_64
- macosx_11_0_arm64
- windows
- win_amd64
- win32
查询自己的 pc 平台:
from distutils.util import get_platform
print(get_platform().replace('-', '_').replace('.', '_'))
常用的是 manylinux2014_x86_64
和 win_amd64
.
pip download --platform manylinux2014_x86_64 --only-binary :all: ...
注意:
- centos 7 可以用
manylinux2014_x86_64
, 但是在 pip 安装时会报版本不兼容的错误 (比如 pyyaml), 为了抑制此错误, 我们可以强制安装: ...
Linux 平台选项详细说明
从新到旧排列:
-
manylinux_<x>_<y>
x, y 指向的是 glibc 的版本, 例如, 如果目标系统的 glibc 版本是 2.28, 则这里填 "manylinux_2_28".
-
manylinux2014_x86_64
-
manylinux2010_x86_64
-
manylinux1_x86_64
-
linux_x86_64
参考:
- https://github.com/pypa/manylinux (opens in a new tab)
- https://stackoverflow.com/questions/49672621/what-are-the-valid-values-for-platform-abi-and-implementation-for-pip-do/49673284 (opens in a new tab)
- https://labs.quansight.org/blog/2020/11/manylinux1-is-obsolete-manylinux2010-is-almost-eol-what-is-next/ (opens in a new tab)