Linux CentOS 环境 下载、安装 Anaconda3、创建虚拟环境

@创建于: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‘.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值