1.下载Anaconda
(1)下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
(2)选择适合您操作系统的版本进行下载
(3)下载方式有两种:
方式一,使用wget下载(注:先下载wget):
sudo apt-get install wget
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.07-1-Linux-x86_64.sh
方式二:在本机下载后,通过xftp等文件上传工具,将工具包上传到服务器
(4)使用uname -m
可以查询系统的位数,如下,我的是x86_64,所以下载的是"Linux-x86_64"
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# uname -m
x86_64
2.安装Anaconda
若您下载的是其它版本,则将该命令的文件名替换为您下载的文件名
sh Anaconda3-2023.07-1-Linux-x86_64.sh
(1)执行Enter(回车)同意继续往下安装
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# bash Anaconda3-2023.07-1-Linux-x86_64.sh
Welcome to Anaconda3 2023.07-1
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
(2)一直回车,但出现输入“yes/no”时,需要输入“yes”才可继续执行,同理,需要输入“ENTER”时,也需执行回车
(3)当询问是否愿意安装程序初始化Anaconda3时,需要输入“yes”
(4)当看到“Thank you for installing Anaconda3!”时,表示conda安装成功
3.启动环境
(1)当输入conda时,会提示“conda: command not found”
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda
conda: command not found
(2)需要输入“source ~/.bashrc”命令,启动配置conda环境
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# source ~/.bashrc
(3)使用“conda info --envs”查询目前已有的环境,可以看到有个“base”环境,且执行(2)之后,命令行前面,就有base,表示当前挂载到了base环境
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda info --envs
# conda environments:
#
base * /root/anaconda3
4.常用命令
4.1创建虚拟环境
(1)如下表示创建一个名为“mycondatest ”、python版本为3.10的虚拟环境,看到输入“yes/no”时,需输入“yes”
conda create -n mycondatest python=3.10
(2)看到如下内容,则表示环境创建成功
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate mycondatest
#
# To deactivate an active environment, use
#
# $ conda deactivate
4.2查询当前系统conda虚拟环境
使用“conda info --envs”命令,可看到多了一个名为“mycondatest”的虚拟环境
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda info --envs
# conda environments:
#
base * /root/anaconda3
mycondatest /root/anaconda3/envs/mycondatest
4.3挂载虚拟环境
使用conda activate mycondatest
命令,挂载名为mycondatest的虚拟环境,如下,可看到由“base”->“mycondatest”
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda activate mycondatest
(mycondatest) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu#
(mycondatest) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu#
4.4退出虚拟环境
使用conda deactivate
命令,退出名为mycondatest的虚拟环境,如下,可看到由“mycondatest”->“base”
(mycondatest) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda deactivate
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu#
4.5查看已安装的工具包
使用conda list
命令,查看当前虚拟环境,已安装的包,基本时当前虚拟环境默认安装的
(mycondatest) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda list
# packages in environment at /root/anaconda3/envs/mycondatest:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
bzip2 1.0.8 h7b6447c_0
ca-certificates 2023.05.30 h06a4308_0
ld_impl_linux-64 2.38 h1181459_1
libffi 3.4.4 h6a678d5_0
libgcc-ng 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
libuuid 1.41.5 h5eee18b_0
ncurses 6.4 h6a678d5_0
openssl 3.0.9 h7f8727e_0
pip 23.2.1 py310h06a4308_0
python 3.10.12 h955ad1f_0
readline 8.2 h5eee18b_0
setuptools 68.0.0 py310h06a4308_0
sqlite 3.41.2 h5eee18b_0
tk 8.6.12 h1ccaba5_0
tzdata 2023c h04d1e81_0
wheel 0.38.4 py310h06a4308_0
xz 5.4.2 h5eee18b_0
zlib 1.2.13 h5eee18b_0
4.6删除虚拟环境
(1)使用conda remove -n mycondatest --all
命令,删除名为mycondatest 的虚拟环境及该环境安装的工具包。注:看到输入“yes/no”时,需输入“yes”
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda remove -n mycondatest --all
Remove all packages in environment /root/anaconda3/envs/mycondatest:
## Package Plan ##
environment location: /root/anaconda3/envs/mycondatest
The following packages will be REMOVED:
_libgcc_mutex-0.1-main
_openmp_mutex-5.1-1_gnu
bzip2-1.0.8-h7b6447c_0
ca-certificates-2023.05.30-h06a4308_0
ld_impl_linux-64-2.38-h1181459_1
libffi-3.4.4-h6a678d5_0
libgcc-ng-11.2.0-h1234567_1
libgomp-11.2.0-h1234567_1
libstdcxx-ng-11.2.0-h1234567_1
libuuid-1.41.5-h5eee18b_0
ncurses-6.4-h6a678d5_0
openssl-3.0.9-h7f8727e_0
pip-23.2.1-py310h06a4308_0
python-3.10.12-h955ad1f_0
readline-8.2-h5eee18b_0
setuptools-68.0.0-py310h06a4308_0
sqlite-3.41.2-h5eee18b_0
tk-8.6.12-h1ccaba5_0
tzdata-2023c-h04d1e81_0
wheel-0.38.4-py310h06a4308_0
xz-5.4.2-h5eee18b_0
zlib-1.2.13-h5eee18b_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(2)执行conda info --envs
命令,可看到只剩下base环境文章来源:https://www.toymoban.com/news/detail-613128.html
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu# conda info --envs
# conda environments:
#
base * /root/anaconda3
(base) root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu#
整理不易,点个赞吧!
整理不易,点个赞吧!
整理不易,点个赞吧!文章来源地址https://www.toymoban.com/news/detail-613128.html
到了这里,关于Ubuntu22.04 安装Anaconda的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!