BOBOBK

Accelerating pip and anaconda in China

TECHNOLOGY

Since the default addresses for pip and anaconda are very slow to access in China, adding domestic mirrors for acceleration is necessary.

Main Domestic Open Source Mirrors

Tsinghua University https://tuna.tsinghua.edu.cn

Alibaba Cloud http://mirrors.aliyun.com

Tencent Cloud https://mirrors.tencent.com

University of Science and Technology of China https://mirrors.ustc.edu.cn

University of Science and Technology of China http://mirrors.ustc.edu.cn

Tongji University http://mirrors.tongji.edu.cn

Adding and Modifying Conda Sources

According to actual speed tests in Shanghai, Tsinghua University’s mirror is the fastest (Tongji University should be faster in theory, but the actual speed is disappointing, 0-0), so we’ll use it as the default source.

Method 1: Add via command line

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

Method 2: Modify configuration file

echo 'channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
channel_priority: strict
show_channel_urls: true
' > ~/.condarc

Adding and Modifying pip Sources

Like conda, directly use Tsinghua University’s mirror.

# Method 1: Use -i to specify address during installation, e.g. installing sklearn
## Temporary
pip install scikit-learn -i "https://pypi.tuna.tsinghua.edu.cn/simple"
## Permanent
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# Method 2: Modify configuration file
mkdir -p ~/.config/pip
echo '[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
' > ~/.config/pip/pip.conf

Summary

Accelerate installation of Python and R packages in China by modifying pip and conda sources.

Related

Python Script to Snatch Recently Expired Domains

TECHNOLOGY
Python Script to Snatch Recently Expired Domains

'Many domain enthusiasts scour forums and websites frantically searching for and snatching up suitable domains, even spending heavily to buy desired domains from their owners. International domain management bodies adopt a "first-to-apply, first-to-register, first-to-use" policy. Since domains only require a small annual registration fee, continuous registration grants you the right to use the domain. Because of this, many domain resellers (commonly known as "domaining pros") often spend heavily on short, easy-to-remember domains. I used to think about buying shorter domains for building scraping sites, but unfortunately, both snatching and buying from others were very expensive. Since it"s first-come, first-served, we can also acquire good domains by registering them before the current owner forgets to renew.'

Solving Expert-Level Sudoku Puzzles Quickly Using Python's Backtracking Algorithm

TECHNOLOGY
Solving Expert-Level Sudoku Puzzles Quickly Using Python's Backtracking Algorithm

I often play Sudoku in my leisure time as a form of relaxation. My usual method involves eliminating duplicates and filling in unique numbers first, then proceeding step by step. However, it's inevitable to guess numbers and adjust based on feedback. So, is there a better algorithm to solve Sudoku puzzles? Here, I will use the backtracking method in Python to solve 9x9 expert-level Sudoku puzzles.