pip与conda换国内源

好的,以下是 pip 和 conda 通过命令行换源的方法:

📦 pip 换源

  1. 临时使用镜像源

    在安装包时直接指定源:

    bash 复制代码
    pip install <包名> -i https://pypi.tuna.tsinghua.edu.cn/simple
  2. 永久配置镜像源

    通过命令修改默认源配置:

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

🐍 conda 换源

  1. 添加清华源

    依次执行以下命令:

    bash 复制代码
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  2. 设置搜索时显示通道地址

    bash 复制代码
    conda config --set show_channel_urls yes
  3. 查看当前配置

    bash 复制代码
    conda config --show

⚠ 注意事项

  1. 镜像源地址需根据网络环境选择(如清华、阿里云等)
  2. 执行后可通过 pip config list 或 conda config --show 验证配置
  3. 某些镜像可能存在同步延迟,若失败可尝试其他源

提示:替换后建议运行 pip cache purge 或 conda clean -i 清除旧索引缓存。

相关推荐
饭来_2 天前
Ubuntu 中出现 CondaToSNonInteractiveError 的解决方法
ubuntu·conda·debug
emo_2b4 天前
Pycharm配置conda解释器时遇到的问题及解决方法
linux·pycharm·conda
Είναι η κοπέλα6 天前
llama.cpp 与 GGUF 格式:本地大模型的“裸引擎“
开发语言·人工智能·pytorch·python·conda
Είναι η κοπέλα7 天前
显存计算与模型选择:你的显卡能跑多大的模型
人工智能·pytorch·python·开源·conda
Escalating_xu7 天前
【Python】使用库:标准库、第三方库、pip、项目实战与程序打包
java·python·pip
天蓝蓝的本我7 天前
conda日常用到的命令积累1-登录linux,安装pycharm
linux·pycharm·conda
青春不朽5129 天前
pip 安装慢、超时、报错?一份国内源配置 + 9 个高频报错对照表
pip
Είναι η κοπέλα10 天前
Python 虚拟环境:venv、conda 与 Python 版本选择全解
开发语言·python·conda
ysu_031411 天前
uv实战指南-从Python版本虚拟环境到pyproject依赖管理
开发语言·python·pip·uv·虚拟环境·包管理·依赖管理