ubuntu18.04 安装 anaconda3 以及创建环境

安装Anaconda3前,ubuntu 自带python3.6,但是会安装失败,需升级python至3.9。
升级过程

wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar -zxf Python-3.9.0.tgz
cd Python-3.9.0
./configure --prefix=/usr/local/python3
 ./configure --enable-optimizations
 make 
 sudo make install

Anaconda3下载
选好目录通过命令下载 或打开网址下载

curl -O https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh

随后安装

bash Anaconda3-2022.05-Linux-x86_64.sh

chmod +777 Miniconda3-latest-Linux-x86_64.sh 
./Miniconda3-latest-Linux-x86_64.sh 

若二次安装要加 -u

./Miniconda3-latest-Linux-x86_64.sh -u

一直按Enter然后输入yes
安装完成后,进入.bashrc添加
export PATH=“/home/ssj/anaconda3/bin:$PATH”

gedit ~/.bashrc
export PATH="/home/ssj/anaconda3/bin:$PATH"
source ~/.bashrc

输入
conda --v
返回conda 4.12.0

安装环境
环境名为test,python版本为3.91

conda create --name test  python=3.9.1

随后会卡在这

Collecting package metadata (current_repodata.json): done Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.

输入

conda config --show-sources

显示.condarc文件目录

==> /home/nico/.condarc <==

输入指令

gedit /home/nico/.condarc 

更改为

allow_conda_downgrades: true
auto_activate_base: false
show_channel_urls: true
ssl_verify: false
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

再次安装环境 成功

conda create --name test  python=3.9.1
conda env list   		//显示环境目录
conda activate test //启动环境
conda deactivate		//退出环境

你可能感兴趣的:(python,linux,ubuntu,anaconda3)