Ubuntu20.04安装miniconda记录

Ubuntu20.04安装miniconda记录

卸载miniconda教程

https://blog.csdn.net/Damien_J_Scott/article/details/136565110

安装到指定路径记录

首先切换到/opt路径,然后从清华源下载镜像

1
2
cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh

下载后进行安装,同时指定安装目录,下面是安装和修改目录的步骤

  1. 安装
1
bash Miniconda3-latest-Linux-x86_64.sh
  1. 修改路径

执行安装指令后,首先会出现类似这样的内容:

1
2
3
4
5
6
Welcome to Miniconda3 py312_24.5.0-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

这时需要按【ENTER】键 然后,会出现一大片内容,让你去读条款,类似这样:

1
2
3
4
5
6
7
8
9
ANACONDA TERMS OF SERVICE

Please read these Terms of Service carefully before purchasing, using, accessing
, or downloading any Anaconda Offerings (the "Offerings"). These Anaconda Terms 
of Service ("TOS") are between Anaconda, Inc. ("Anaconda") and you ("You"), the 
individual or entity acquiring and/or providing access to the Offerings. These T
OS govern Your access, download, installation, or use of the Anaconda Offerings,
 which are provided to You in combination with the terms set forth in the applic
able Offering Description, and are hereby incorporated into these TOS. 

这时直接按【Ctrl+C】跳过即可 跳过后,最后一行会问你是否接受许可证条款,大概内容是这样的:

1
2
Do you accept the license terms? [yes|no]
>>>

这里输入:yes 然后关键的部分来了,接下来会提示你要安装到默认路径还是自己选择其他路径,大概内容是这样的:

1
2
3
4
5
6
7
8
Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/miniconda3] >>>

这时要输入自己想安装的路径,而不是按ENTER,所以这里输入:

1
/opt/miniconda3

输入后,最后一行应该是这样的:

1
[/root/miniconda3] >>> /opt/miniconda3

这时就可以按【ENTER】了,按下后就会进行安装 执行到这部分后,又需要输入一次yes

1
2
3
4
5
6
7
8
9
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>>

输入:yes 然后命令行输出如下内容:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
no change     /opt/miniconda3/condabin/conda
no change     /opt/miniconda3/bin/conda
no change     /opt/miniconda3/bin/conda-env
no change     /opt/miniconda3/bin/activate
no change     /opt/miniconda3/bin/deactivate
no change     /opt/miniconda3/etc/profile.d/conda.sh
no change     /opt/miniconda3/etc/fish/conf.d/conda.fish
no change     /opt/miniconda3/shell/condabin/Conda.psm1
no change     /opt/miniconda3/shell/condabin/conda-hook.ps1
no change     /opt/miniconda3/lib/python3.12/site-packages/xontrib/conda.xsh
no change     /opt/miniconda3/etc/profile.d/conda.csh
modified      /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

Thank you for installing Miniconda3!

这时就安装并成功修改路径了 可以通过ls指令看一下miniconda是否安装到这个路径了

1
ls /opt/miniconda3

输出如下:

1
2
3
4
bin              condabin    include      pkgs   ssl
cmake            conda-meta  lib          sbin   x86_64-conda_cos7-linux-gnu
compiler_compat  envs        LICENSE.txt  share  x86_64-conda-linux-gnu
_conda           etc         man          shell

说明成功安装到该路径下了

手动将miniconda路径添加至环境中记录

首先测试conda命令是否能正常使用,如果能正常使用就不用添加了 输入conda -V 如果正常输出conda版本则不需要手动添加,如果显示:

1
conda:未找到命令

就需要手动将miniconda的路径添加到环境中 首先打开环境配置文件:

1
sudo vim /etc/profile

在文件末尾添加这行代码:

1
export PATH="/opt/miniconda3/bin:$PATH"

然后输入:wq!,退出文件并保存,修改后注入环境

1
sudo source /etc/profile

再输入conda -V,即可正常输出:

1
conda 24.5.0

安装并配置好环境后,需要重启终端才能切换环境

给conda换源

  1. 显示所有channel
1
conda config --show channels

默认config中的channels如下:

1
2
3
(base) root@xh-X99:/opt# conda config --show channels
channels:
  - defaults

(记录一下显示所有config信息的指令:conda config --show) 2. 添加源

1
2
3
4
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
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/

并设置从channel中安装包时显示channel的url:

1
conda config --set show_channel_urls yes
  1. 删除源 如果有哪个源想删除可以参考这个指令:
1
conda config --remove channels <源地址>

以上面添加源的第一条为例,想要删除时,就是输入:

1
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
0%