ubuntu 系统apt-get, pip , conda各种国内源的总结

本文详细介绍了如何在Ubuntu系统中配置不同的软件包管理源,包括APT、pip和conda,以提高软件安装效率。针对不同版本的Ubuntu,提供了具体的源配置方法,同时强调了配置前的备份操作。
部署运行你感兴趣的模型镜像

原创文章,欢迎转载,注明出处。

1 系统级别的软件。  

主要设置apt-get的源,有两种方法。第一种 /etc/apt/sources.list  

设置后效果如下:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse

#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse

#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse

#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse

# 预发布软件源,不建议启用

# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

 

bionic 为ubuntu 的版本代号,main 为完全的自由软件,resticted 受限的自由软件,

universe 社区提供补丁与支持,multiverse: 不提供补丁与支持。

第二种方式为使用安装系统时自带的软件,software & updates,可以方便的管理源。

 

2 pip install 的安装源。

配置文件在~/.pip 文件夹下  pip.config

配置完后如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host = pypi.tuna.tsinghua.edu.cn

使用文件编辑器修改如果引发报错的话,尤其是windows的anaconda

可以使用命令修改:pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

 

 

3 conda 源

配置文件为.condarc 位于家目录下。配置完后为:

channels:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

  - https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

  - defaults

show_channel_urls: true

ssl_verify: true

windows 下安装anaconda后如果修改 C盘里面 .condarc 后重新启动anaconda navigator 会报错,需要删掉.condarc

重启,错误会消失

出错的情况下可以使用命令行修改:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

 

最有需要注意,apt-get 的源修改要对应到自己的版本 bionic(18.04),其余版本

代号自行查阅。另在修改配置文件前最好备份原来文件,避免失效导致软件安装不了。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

<think>好的,我现在需要帮助用户解决通过apt-get安装build-essential、python-pip以及clang-format-3.8的问题。首先,我应该回顾用户提供的引用内容,看看有没有相关的安装步骤可以参考。 用户提到了三个引用,其中引用[1]中有安装python3-pip的命令,引用[3]提到了安装build-essential和wget的步骤。所以,我需要将这些信息整合起来。 首先,build-essential是必须安装的,因为它包含了编译所需的工具,比如gcc和make。用户引用[3]中确实有使用apt-get install build-essential的命令,所以这部分可以直接参考。 接下来是python-pip。但注意到引用[1]中使用的是python3-pip,因为现在大多数系统默认使用Python3,所以应该建议用户安装python3-pip而不是旧的python-pip(对应Python2)。不过用户明确提到了python-pip,可能需要确认是否用户确实需要Python2的版本,但考虑到Python2已经过时,可能需要提醒用户使用Python3的版本。 然后是clang-format-3.8。这个包可能需要特定的仓库或者版本支持。在Ubuntu中,不同版本的clang-format可能存在于不同的软件中。例如,较新的Ubuntu版本可能没有clang-format-3.8,需要添加旧的仓库或者使用其他方式安装。如果直接使用apt-get安装的话,可能需要检查是否可用,或者建议用户安装其他版本,或者通过其他途径获取。 现在,我需要检查这些包在Ubuntu中的可用性。例如,对于Ubuntu 20.04或22.04,默认的软件中是否有clang-format-3.8?可能需要用户添加特定的仓库,比如LLVM的官方仓库,或者使用snap安装。但用户希望使用apt-get,所以如果该版本不存在于默认中,可能需要说明如何添加,或者建议安装其他版本。 此外,用户引用[3]中提到了更新apt-get,所以应该先建议用户执行sudo apt-get update来更新软件列表,确保可以找到最新的包。 总结步骤: 1. 更新软件包列表:sudo apt-get update 2. 安装build-essential:sudo apt-get install build-essential 3. 安装Python3的pip:sudo apt-get install python3-pip 4. 安装clang-format-3.8:可能需要检查是否存在,如果不存在,可能需要添加仓库或使用其他方法。例如,在Ubuntu 18.04中,clang-format-3.8可能在universe仓库中可用,但需要启用。如果不可用,可能需要下载deb包或者使用其他版本。 不过,用户明确要求安装clang-format-3.8,所以如果无法通过apt-get直接安装,可能需要提供替代方案,比如安装其他版本或者从码编译。 现在,我需要确认这些步骤是否正确,以及如何处理clang-format-3.8的安装问题。根据经验,clang-format的版本通常与LLVM版本对应,而Ubuntu的默认可能不包含较旧的版本。例如,Ubuntu 20.04可能默认提供clang-format-10或更高版本。因此,用户可能需要添加LLVM的旧版本仓库,或者寻找其他方式安装。 但是,如果用户坚持使用apt-get,可能需要指导他们添加相应的仓库。例如,LLVM的官方仓库提供了不同版本的包,可以通过脚本添加。例如,使用以下命令: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 3.8 然后安装clang-format-3.8。但这个过程可能比较复杂,或者需要用户信任外部脚本。或者,可能直接说明该版本已不可用,建议安装更新的版本,如clang-format-14,并调整版本号使用。 但用户可能由于项目需要必须使用3.8版本,这时候可能需要更详细的步骤,比如下载deb包手动安装,或者从码编译。不过这会超出apt-get的范围,所以可能需要说明这种情况。 综上,回答应该包括: - 更新软件 - 安装build-essential和python3-pip - 尝试安装clang-format-3.8,如果不可用,建议检查可用版本或添加仓库 同时,根据用户提供的引用,引用[1]中的命令使用了sudo apt-get install python3-pip,所以应该建议安装python3-pip,并指出python-pip可能对应Python2,而Python2已不再维护,推荐使用Python3。 对于clang-format-3.8,可能需要告知用户该版本可能不在默认仓库中,可以尝试安装其他版本,或者通过其他途径。例如,用户可能需要启用universe仓库,或者添加LLVM的仓库。 可能的步骤: sudo apt-get update sudo apt-get install build-essential python3-pip sudo apt-get install clang-format-3.8 如果第三步失败,建议用户搜索可用版本: apt search clang-format 或者尝试添加旧版仓库: sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" sudo apt-get update sudo apt-get install clang-format-3.8 如果还是不可用,可能需要告知用户无法通过apt-get安装,建议使用其他方法,或者安装较新版本如clang-format-14,并使用update-alternatives来设置默认版本。 但用户可能希望具体的解决方案,所以可能需要更明确的指导。例如,在Ubuntu 16.04(Xenial)中,clang-format-3.8可能在universe仓库中存在,但在更新的系统中可能已被移除。因此,可能需要根据用户的系统版本进行调整。 由于用户的问题中没有说明Ubuntu版本,可能需要给出一般性建议,并提示版本差异。 此外,用户引用[3]中提到了安装anacondaconda init,但可能与当前问题无关,除非用户需要Python环境管理,但当前问题主要涉及构建工具和clang-format。 现在,整理回答: 首先,安装build-essential和python3-pip,这两个可以直接通过apt-get安装。然后,对于clang-format-3.8,可能需要启用universe仓库,更新,再尝试安装。如果不行,可能需要说明该版本不可用,建议安装其他版本,或者使用其他方法。 在回答中,需要结合用户提供的引用内容,特别是引用[1]和[3]中的相关命令,并正确引用。 最后,生成相关问题,比如如何检查已安装的clang-format版本,如何添加软件仓库,或者如何安装特定版本的软件包。</think>### 安装步骤说明 1. **更新软件包列表** 安装前建议先更新软件信息以确保获取最新版本: ```bash sudo apt-get update ``` 2. **安装构建工具 `build-essential`** 该工具链包含 `gcc`、`make` 等基础编译工具[^3]: ```bash sudo apt-get install build-essential ``` 3. **安装 Python 包管理工具 `pip`** 建议安装 Python3 版本的 `pip`(Python2 已停止维护)[^1]: ```bash sudo apt-get install python3-pip ``` 4. **安装 `clang-format-3.8`** 该工具可能需要启用 `universe` 仓库。若安装失败,可尝试以下操作: ```bash sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" sudo apt-get update sudo apt-get install clang-format-3.8 ``` **注意**:若系统版本较新(如 Ubuntu 20.04+),可能已移除旧版 LLVM 工具链。此时可通过以下方式解决: - 安装其他版本(如 `clang-format-14`)后通过符号链接适配: ```bash sudo apt-get install clang-format-14 sudo ln -s /usr/bin/clang-format-14 /usr/bin/clang-format-3.8 ``` - 或通过码编译安装(需参考 [LLVM 官方文档](https://releases.llvm.org/))。 --- ### 验证安装 - 检查 `clang-format` 版本: ```bash clang-format-3.8 --version ``` - 检查 `pip` 版本: ```bash pip3 --version ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值