Miniconda installation + source change under Ubuntu 22.04 LTS (stepping on the pit direction)

1. Install Miniconda

        I am using Python3.8, if you need to go to other corresponding versions, please check 

        Miniconda — conda documentation

#Download
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh
#Install (if you need to change the installation path, you need to add -u at the end)
sudo bash Miniconda3-py38_23. 1.0-1-Linux-x86_64.sh -u
# Under normal circumstances, it should enter the base environment directly after installation
# Use the following command to prevent the terminal from entering the base environment by default
conda config --set auto_activate_base false

        Question 1: After the installation is complete, I did not directly enter the base environment, and conda did not add environment variables

        1.1 Manually add environment variables and enter the base environment

                Modify the /etc/profile file

sudo vim /etc/profile

               Then at the end add

export PATH=/home/wind/Programme/Program/Miniconda3/bin:$PATH

                update profile file

source /etc/profile

                If it still doesn't work, try rebooting

                Activate the base environment

conda activate base

                If you find that the conda activate base is not available after completion, restart it

                Exit the base environment

conda disabled

 2. Miniconda source change

        Replace Tsinghua source here

        2.1 Generate .condarc file

                If there is no such file under /home/username, it needs to be generated. Unfortunately, I don’t have it

conda config --set show_channel_urls yes

                Open the .condarc file

sudo vim ~/.condarc

        2.2 Modify the .condarc file

        Add at the end of the .condarc file, then: wq save and exit

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/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

                make sure to join

conda config --show-sources 

                The display should look like this:

==> /home/wind/.condarc <==
auto_activate_base: False
channels:
  - defaults
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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
default_channels:
  - 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/msys2
show_channel_urls: True 

3. Create a virtual environment

        Create a virtual environment named AI_3.8, using python 3.8 (modify yourself as needed)

create create -n AI_3.8 python==3.8

        pip change source (Douban source)

pip config set global.index-url https://pypi.douban.com/simple/

pip config set install.trusted-host pypi.douban.com

4. Miniconda uninstall
        If the wrong version is installed, you can uninstall Miniconda and install the correct version.
        First find the Miniconda installation location, which is under the /home folder by default. Find the miniconda3 folder. If it is not in the /home folder, you can use the command to find it :

find -name miniconda3

        Find the corresponding folder and delete the folder

rm -rf Miniconda3

         Then open the ~/.bashrc file:

vim ~/.bashrc

        Comment the commands related to conda with #

Reference blog:

(3 messages) Ubuntu20+Miniconda3+Python3 installation and configuration environment (manually add environment variables, replace Tsinghua source)_ubuntu miniconda add environment variables_Earlybird、's Blog-CSDN Blog

(5 messages) Ubuntu installation and uninstallation Miniconda_ubuntu uninstall miniconda

(3 messages) Ubuntu installs Miniconda and configures domestic sources_ubuntu miniconda change source_Yugongbuyishan's Blog-CSDN博客

Guess you like

Origin blog.csdn.net/qsdftuyiop/article/details/129950407