Install anaconda on Ubuntu, build the environment, and change domestic sources

Install anaconda on Ubuntu, build the environment, and change domestic sources

One, anaconda download

Use the browser in Ubuntu to open the link: link to download the anaconda installation package
insert image description here

2. Installation

1. Under the file in the same directory (open the terminal where the file is), command ctrl+alt+T to open the terminal
2. Enter bash Anaconda3-5.2.0-Linux-x86_64.sh (for the downloaded anaconda installation file )
3. Other default installations, enter the registration interface, enter yes
insert image description here
4. Read the registration information, and then enter yes; check the location of the file to be installed, press enter, and you can install
insert image description here
5. After the installation is complete, you will receive a prompt to add environment variables information, enter yes
insert image description here
6. See the information in the figure below, indicating that the installation has been completed.
insert image description here
7. Prompt message "Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]", enter no
8. Restart the terminal, you can use Anaconda3

Note: If you enter python in the terminal, the Python version that comes with Ubuntu will still be displayed, because the environment variable was not successfully added in step 5, we execute: input: exit() to exit Manually add environment variables
:

sudo gedit ~/.bashrc
export PATH="/home/你的计算机名字/anaconda3/bin:$PATH"(路径)
source ~/.bashrc

3. Environment construction

1. Open the command terminal with Ctrl+alt+T
2. Create the environment:

conda create -n tf python=3.6

insert image description here*** PS: tf is the environment name, you can set it by yourself ***
3. Start the environment:

source activate tf

insert image description here

Four, conda common commands

conda --version #查看conda版本,验证是否安装

conda update conda #更新至最新版本,也会更新其它相关包

conda update --all #更新所有包

conda update package_name #更新指定的包

conda create -n env_name package_name #创建名为env_name的新环境,并在该环境下安装名为package_name 的包,可以指定新环境的版本号,例如:conda create -n python2 python=python2.7 numpy pandas,创建了python2环境,python版本为2.7,同时还安装了numpy pandas包

source activate env_name #切换至env_name环境

source deactivate #退出环境

conda info -e #显示所有已经创建的环境

conda create --name new_env_name --clone old_env_name #复制old_env_name为new_env_name

conda remove --name env_name –all #删除环境

conda list #查看所有已经安装的包

conda install package_name #在当前环境中安装包

conda install --name env_name package_name #在指定环境中安装包

conda remove -- name env_name package #删除指定环境中的包

conda remove package #删除当前环境中的包

conda create -n tensorflow_env tensorflow

conda activate tensorflow_env #conda 安装tensorflow的CPU版本

conda create -n tensorflow_gpuenv tensorflow-gpu

conda activate tensorflow_gpuenv #conda安装tensorflow的GPU版本

conda env remove -n env_name #采用第conda remove --name env_name –all的方法删除环境失败时,可采用这种方法

Five, conda for domestic sources

1. 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/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

2. China Science and Technology University

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda config --set show_channel_urls yes

Guess you like

Origin blog.csdn.net/qq_40276082/article/details/130196213