Linux installs Anaconda/Miniconda and configures the environment
Article directory
This article is mainly used to record some of the problems I encountered when using Anaconda/Miniconda to create a python virtual environment on the Feiteng Jiangniu development board (ARM architecture) .
1. Anaconda download
1. Official website download
2. Tsinghua mirror download
Download Linux 64-Bit (x86) installer
Note:
If you are installing Anaconda on ARM architecture, download the Linux 64-Bit (ARM64) installer
Otherwise, the following error will appear:
If you download Linux 64-Bit (ARM64) installer and run the following error message:
You need to lower the Anaconda version and use miniconda3 4.9 version to perfectly solve this problem.
Pull the conda installation package
wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.9.2-Linux-aarch64.sh
2. Installation
Run in the downloaded installation package path
bash Anaconda3-2023.07-1-Linux-x86_64.sh
The version downloaded by the installation package will be different.
Press Enter to view the agreement and continue,
Until you see Please answer 'yes' or 'no' , enter yes ;
3. Add environment variables
First, check whether Anaconda automatically configures environment variables:
source ~/.bashrc
Execute conda again. If the following figure shows that Anaconda has automatically configured the environment variables
4. Conda manages virtual environment
1. Conda creates a virtual environment
Create a virtual environment
conda create -n my_env python=3.8.2
View existing virtual environments
conda env list
2. Conda activates the virtual environment
activation
conda activate my_env
Deactivate
conda deactivate
3. Cancel automatic entry into base environment
conda config --set auto_activate_base false
4. conda source change
Tsinghuayuan
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 --set show_channel_urls yes
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
5. conda manages installation sources
View installed sources
conda config --show-sources
Delete installation source
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Restore default source
conda config --remove-key channels
pip source change
pip install pkg -i http://pypi.douban.com/simple
Other ways to change sources with conda
Use Vim to edit the .condarc file in the root directory
vim ~/.condarc
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/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
reference
Configuring the conda environment in Linux and changing the source - Zhihu (zhihu.com)
Steps to install Anaconda under Ubuntu (with pictures) - Zhihu (zhihu.com)