配置国内镜像源加速Python包安装

pip install pandas sentence-transformers scikit-learn openpyxl

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

清华源

https://pypi.tuna.tsinghua.edu.cn/simple

阿里源

http://mirrors.aliyun.com/pypi/simple/

配置国内镜像源加速Python包安装

使用国内镜像源可以显著提升pip安装Python包的速度。以下是两种常用镜像源的配置方法和使用示例:

清华源

复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

阿里源

复制代码
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

安装指定包组命令

执行以下命令安装pandas等常用数据科学包:

bash 复制代码
pip install pandas sentence-transformers scikit-learn openpyxl

临时使用镜像源方法

若不想修改全局配置,可在安装命令中临时指定源:

bash 复制代码
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package_name

验证配置是否生效

检查当前pip源配置:

bash 复制代码
pip config list

常见问题解决

安装时出现SSL错误可尝试添加信任参数:

bash 复制代码
pip install --trusted-host pypi.tuna.tsinghua.edu.cn -i https://pypi.tuna.tsinghua.edu.cn/simple package_name