Install anaconda under ubuntu20.04 + configure environment variables + run + create shortcuts

It turned out that matlab was used for data processing and algorithm verification under windows, and C++ deployment and application was performed under ubuntu, which required constant restart and switching of dual systems, which was too troublesome. I planned to use python for data processing and algorithm verification under ubuntu. Install anaconda as follows

1. Download anaconda from the official website

Free Download | Anaconda

2. Install, open a command window under the folder, enter

bash Anaconda3-2022.10-Linux-x86_64.sh

Specifically, it is renamed according to the anaconda version.

3. Follow the prompts all the way to install, you need to hit enter and yes, etc., until the prompt anaconda3 installation is successful.

4. After installing anaconda, using conda to create an environment , the result is an error:

bash: conda: command not found

This is mainly because conda has not been included in the environment variable. The solution is as follows:

  • 1. Open the file bashrc:

vim ~/.bashrc

  • 2. Add the path of anaconda at the end of the pop-up file:

export PATH=~/home/anaconda3/bin:$PATH

After opening the file, press i to enter the editing mode, press Esc to exit the editing mode, shift+colon and then enter wq to save the file and exit
Note: This is the installation path of anaconda, just according to your own installation path

  • 3. Activate environment variables

source ~/.bashrc

After performing the above three steps, you can use the conda command on linux!
5. Enter in the command window

conda list

can be displayed.

6. Open the spyder IDE in it

  • Open the environment (the automatic start button was turned off during the previous installation, and it needs to be restarted. conda activate base, the front will display (base), ( base) XXXX @XXXX-Laptop-17-ck1xxx:~$
  • anaconda-navigator opens the user interface, and then select the spyder icon to open the spyder IDE.

7. Other commands

#View the installed version of Anaconda
conda --version
#View the installed environment
conda env list
#Create environment
conda create -n (environment name) python(==3.7.4)
#Check whether the creation is successful
conda info --envs
# Activate the environment
conda activate (environment name)
#Exit the environment
conda deactivate (environment name)
#Delete the environment
conda remove -n (environment name) --all
 #Set whether to automatically open the environment

conda config --set auto_activate_base true

conda config --set auto_activate_base false

8. Create a desktop shortcut

  • Open the terminal and enter the /usr/share/applications folder: cd /usr/share/applications
  • Create the anaconda.desktop file sudo gedit anaconda.desktop
  • Add the following content to the anaconda.desktop file and save it: [Desktop Entry]
    Name=Anaconda
    Version=1.0
    Type=Application
    Exec=/home/kim/anaconda3/bin/anaconda-navigator
    Icon=/home/kim/anaconda3/pkgs/ anaconda-navigator-2.3.1-py39h06a4308_0/lib/python3.9/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
    Terminal=false
    StartupNotify=true
  • Note: Exec and Icon above are the navigation of the application and the icon of the program respectively, remember to change it yourself!
  • Open "Show Applications", find the Anaconda icon in the program list, and drag it to the quick launch bar!
  • Finish

Guess you like

Origin blog.csdn.net/weixin_45834800/article/details/130889928