# 使用国内镜像源安装
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple
# 最好是设置默认镜像源,后续pip安装模块都使用国内镜像源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# myenv为虚拟环境名称,如果有多个python版本也可以指定具体版本
python3 -m venv myenv
python3.11 -m venv myenv
# 激活虚拟环境
source myenv/bin/activate
# 删除虚拟环境,直接删除目录
rm -rf myenv
# 安装PyTorch模块
pip install torch
# 安装transformers模块, 使用huggingface
# 模型下载默认保存路径:/Users/用户名/.cache/huggingface/hub
pip install transformers
# 已有项目依赖模块安装
pip install -r requirements.txt
注意,pip可能使用pip3代替
# 如果出现Connection to huggingface.co timed out
vim ~/.bash_profile
export HF_ENDPOINT=https://hf-mirror.com