@创建于:20220308
@修改于:20230501
@TOC
1、下载
在官网下载地址,右击,复制链接
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
2、安装
(1)在b shell中安装
bash Anaconda3-2020.07-Linux-x86_64.sh
(2)回车键,进入注册信息页面
(3)按q跳过阅读,yes
Do you accept the license terms? [yes|no]
[no] >>> yes
(4)默认安装在用户目录下,直接回车即可安装;若想自定义安装目录,直接输入安装目录(如/home/anaconda3),回车即可。
Anaconda3 will now be installed into this location:
/root/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/root/anaconda3] >>> /home/anaconda3
PREFIX=/home/anaconda3
Unpacking payload ...
Installing base environment...
Downloading and Extracting Packages
Downloading and Extracting Packages
Preparing transaction: done
Executing transaction: |
Installed package of scikit-learn can be accelerated using scikit-learn-intelex.
More details are available here: https://intel.github.io/scikit-learn-intelex
For example:
$ conda install scikit-learn-intelex
$ python -m sklearnex my_application.py
done
installation finished.
(5)Do you wish the installer to initialize Anaconda3 by running conda init ? 输入 no,回车
选择前请参考:Linux安装anaconda3是否初始化的区别
(6)自己根据需要,修改环境变量
- vim ~/.bashrc
# anaconda3/bin的真实路径,与步骤(4)对应起来。
export PATH=/home/anaconda3/bin:$PATH
- source ~/.bashrc
(7)检查是否安装成功
- conda --version
Linux安装anaconda
Linux下安装Anaconda 详细过程 搭建python环境
3、创建虚拟环境
3.1 创建环境
# 创建一个名称为tsp的python版本为3.8.5的虚拟环境
conda create -n tsp python=3.8.5
3.2 激活虚拟环境时候报错及解决
问题:IMPORTANT: You may need to close and restart your shell after running ‘conda init’
[root@localhost ~]# conda activate tsp
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
[root@localhost ~]# conda activate tsp
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
[root@localhost ~]# source activate
(base) [root@localhost ~]# conda activate tsp
(tsp) [root@localhost ~]#
请注意图片中的红框内容
参考链接:conda activate激活环境出错的解决办法
下面博客不加conda。我也不清楚为什么。
IMPORTANT: You may need to close and restart your shell after running ‘conda init‘.