各種鏡像源的更換


各種鏡像源的更換

索引:

樹莓派

Anaconda

PIP/PIP3

Ubuntu

樹莓派

本次采用的是一塊樹莓派3B-PLUS的板子

樹莓派的版本信息確定

查看樹莓派的版本信息的幾種方式:

  • uname -a

    Linux raspberrypi 4.19.57-v7+ #1244 SMP Thu Jul 4 18:45:25 BST 2019 armv7l GNU/Linux
  • lsb_release -a

    No LSB modules are available.
    Distributor ID: Raspbian
    Description:    Raspbian GNU/Linux 10 (buster)
    Release:    10
    Codename:   buster
  • 使用軟件查看:

    • 通過命令下載:sudo apt install screenfetch

    • 下載成功后,輸入命令screenfetch,查看

        .',;:cc;,'.    .,;::c:,,.    pi@raspberrypi
       ,ooolcloooo:  'oooooccloo:    OS: Raspbian 10 buster
       .looooc;;:ol  :oc;;:ooooo'    Kernel: armv7l Linux 4.19.57-v7+
         ;oooooo:      ,ooooooc.     Uptime: 11m
           .,:;'.       .;:;'.       Packages: 1446
           .... ..'''''. ....        Shell: 858
         .''.   ..'''''.  ..''.      DE: LXDE 
         ..  .....    .....  ..      WM: OpenBox
        .  .'''''''  .''''''.  .     CPU: ARMv7 rev 4 (v7l) @ 1.4GHz
      .'' .''''''''  .'''''''. ''.   RAM: 183MiB / 874MiB
      '''  '''''''    .''''''  '''  
      .'    ........... ...    .'.  
        ....    ''''''''.   .''.    
        '''''.  ''''''''. .'''''    
         '''''.  .'''''. .'''''.    
          ..''.     .    .''..      
                .'''''''            
                 ......   

總結

從上述三種方式中,可以看出其操作系統為Raspbian 10 buster,有了這條信息,即可進行后續的換源操作。

換源

可參考清華站的使用幫助即可:https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/

  • 進入上述網站;

  • 使用說明欄中選擇之前查詢的樹莓派操作系統的版本,例如我的為Debian 10

    • 千萬不要選錯版本!

  • 編輯 /etc/apt/sources.list文件,將其中的內容修改為:

    deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
    deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib

    將原先的內容用#+space注釋掉即可

  • 再編輯/etc/apt/sources.list.d/raspi.list文件,將其中內容修改為:

    deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
  • 編輯鏡像站后,使用sudo apt-get update命令,更新軟件源列表,同時檢查方才的編輯是否正確。

Anaconda換源

參照清華站使用幫助:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

  • 找到用戶目錄下的 .condarc文件:

    • Windows 用戶無法直接創建名為 .condarc 的文件,可在Anaconda Prompt中執行 conda config --set show_channel_urls yes 生成該文件之后再修改

  • 將其內容修改為:

    channels:
      - defaults
    show_channel_urls: true
    default_channels:
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    custom_channels:  # 這部分內容有需要再添加即可,一般也不需要添加
      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/anaconda/cloud
      simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  • 若想恢復源,則通過輸入命令:conda config --remove-key channels即可

PIP/PIP3的換源

  • 升級pip

    此處推薦將pip升級為pip3,采用命令為:python -m pip install --upgrade pip

參照清華站使用幫助:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

  • 臨時使用,推薦

    • 命令為pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 包的名字

  • 永久:

    • 升級 pip 到最新的版本 (>=10.0.0) 后進行配置:

    pip install pip -U
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
    • 如果您到 pip 默認源的網絡連接較差,臨時使用本鏡像站來升級 pip:

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

Ubuntu換源

主要參考清華的開源軟件鏡像站即可:傳送門->Ubuntu 鏡像使用幫助,其實查看網站的提示信息就可以了

事無巨細:通過命令lsb_release -a確定你的系統版本是Ubuntu 16.04 LTS/Ubuntu 18.04 LTS...

根據網站中提供的網址,將原先的sources.list的文件做相應的替換即可,非常的方便:-)

最后:通過如下命令sudo apt update,做一下更新即可

當然,最好將系統自帶的該文件做個備份

參考:

https://jingyan.baidu.com/album/ca00d56c144644e99febcf4d.html?picindex=3

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/

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

https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM