Raspberry Pi raspberry pi replaces the domestic image

Sometimes when using sudo apt-get and pip install to install software and some libraries, the download speed is simply slow as shown in the figure below: because in the default state of the system, the installation software will choose to download the software from a foreign server. The default address is http://raspbian.raspberrypi.org

The official also gives the software source address of each country in the world, here only introduces the official document of Tsinghua University's software source modification method.

1. First enter the following command on the command line to check the system version of your Raspberry Pi as shown in the figure below:

lsb_release  -a

2. Open the Tsinghua official document to find your corresponding version as shown below:

2. Enter the following command and use # to log out the original source, do not delete it, so as not to know what to do if you want to restore it in the future:

sudo nano /etc/apt/sources.list

Then copy the following content and paste it at the top of the file as shown below:

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

Then press Ctrl+o to save and confirm, Ctrl+x to exit editing

(Note: The buster here is my own Raspberry Pi system version, check your own system version first)

3. Enter the following command

sudo nano /etc/apt/sources.list.d/raspi.list

Enter the edit page, use # to log out the original content, copy the following content, and then paste it in, ctrl + o to save and confirm, and Ctrl + x to exit as shown below:

deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

At this point, the solution to the slow download of apt-get is completed

Enter sudo apt-get update to verify as shown below:

Much faster than before the change

The solution to the slow download of pip install is also briefly introduced here:

  1. The first is to add the parameter -i https://pypi.tuna.tsinghua.edu.cn/simple when using pip install  .

For example:

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

-i  https://pypi.tuna.tsinghua.edu.cn/simple  This is the mirror source, followed by pygame is the package and library to be installed

The above is temporary.

If you install a third-party package plus a domestic mirror source and still prompt the Could not fetch URL  problem, use the following method

Sometimes some libraries need to add this source and it will prompt an error. It may be that the website is not trusted. You can try it in the following way: --trusted-host  http://pypi.douban.com  means to set the specified website as a trusted server to Douban mirror example host followed by a mirror website

The mirror sites are as follows:

Commonly used mirror addresses are:

1  ) http://mirrors.aliyun.com/pypi/simple/Aliyun

2) https://pypi.mirrors.ustc.edu.cn/simple/  University of Science and Technology of China

 ) http://pypi.douban.com/simple/Douban

4)  https://pypi.tuna.tsinghua.edu.cn/simple/Tsinghua  University

5)  http://pypi.mirrors.ustc.edu.cn/simple/  University of Science and Technology of China


pip install xxx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com 
xxx表示要安装的模块名

2. There is also a timely, permanent modification once and for all.

Enter the following command to update pip

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

When finished, enter the following command:

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

Finish.

Guess you like

Origin blog.csdn.net/great_yzl/article/details/128989940