问题365网经验知识百科全书!

【2022】Centos7.4安装anaconda3(anaconda2022.11)

0次浏览 | 2023-09-02
来源 :daniel
一、下载anaconda

如果你要将anaconda共享给同一主机的其他用户使用,不要用root用户安装anaconda,其他用户无法共享root用户的anaconda。我的服务器就我一个人使用,我还是选择root用户安装。

1.1 进入清华镜像源下载anaconda

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh

可能提示:

错误: 无法验证 mirrors.tuna.tsinghua.edu.cn 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书: 颁发的证书已经过期。

修改命令:

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh --no-check-certificate

提示没有wget

安装即可

yum -y install wget

二、安装anaconda 2.1 进入下载目录执行文件

bash Anaconda3-2021.11-Linux-x86_64.sh

提示Do you accept the license terms? [yes|no],输入yes

Do you accept the license terms? [yes|no][no] >>> Please answer 'yes' or 'no':>>> yes

2.2 是否要修改安装路径,如果不修改就直接按回车(Enter)确认

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] >>>

如果需要修改,就输入要安装到的绝对路径

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] >>> /opt/anaconda3

提示找不到bunzip2

Anaconda3-2021.11-Linux-x86_64.sh: line 353: bunzip2: command not foundtar: This does not look like a tar archivetar: Exiting with failure status due to previous errors

安装bzip2即可:

yum install -y bzip2

解决完bzip2后,重复前面的步骤安装anaconda3

2.3 是否需要进行conda的初始化

若选择yes,会在/root/.bashrc目录中自动添加环境变量,会使得开机自动启动base环境。

如果选择了no,需要自行配置conda命令环境变量。这也是为什么出现-bash: conda: 未找到命令的原因

2.4 安装成功

Thank you for installing Anaconda3!===========================================================================Working with Python and Jupyter notebooks is a breeze with PyCharm Pro,designed to be used with Anaconda、Download now and have the best datatools at your fingertips.PyCharm Pro for Anaconda is available at: https://www.anaconda.com/pycharm

三、配置anaconda 3.1 conda初始化选择yes

这时候conda命令是可以直接使用的,输入几条命令测试一下

source activate # 进入conda环境 出现(base)则说明安装成功conda deactivate # 退出conda环境

3.2 conda 初始化选择no

这时候conda命令无法使用,需要我们自行配置环境变量,方法也很简单

3.2.1 打开profile文件

vim /etc/profile

3.2.2 在文件的最后加入如下内容(我使用的是默认安装路径,如果你修改了安装路径,就需要根据自己 的安装路径修改path的内容)

vim跳转到文件头和文件末尾的命令:

gg : 跳转到文件头

Shift+g : 跳转到文件末尾

行数+gg : 跳转到指定行,例跳转到123行:123gg

shift+gg跳转到最后一行,输入o就可以快速添加新的一行,然后添加。

PATH=$PATH:/root/anaconda3/binexport PATH

3.2.3 退出并保存

按下 Esc ,然后输入:wq,就退出vim,并保存了文件。

3.2.4 刷新环境变量

source /etc/profileecho $PATH

3.2.5 测试anaconda

conda activate # 进入conda环境 出现(base)则说明安装成功conda deactivate # 退出conda环境

如果输入conda activate,提示提示“CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’.”错误

那么应该使用source activate

具体原因可以参考:linux下的source命令

四、使用anaconda创建环境

anaconda创建环境的命令为

conda activate -n 环境名 python==python版本

创建一个名为spider,python版本为3.8的环境

conda create -n spider python==3.8

提示Proceed ([y]/n)?,输入y。

激活spider的环境,出现(spider)即成功。

conda activate 环境名

conda activate spider

在新的环境中安装包

pip install 包名

python语言属于什么语言?Python特点主要有哪些?
目前,Python已经成为求职中最吃香的三大编程语言之一,而且相较于C、C++、Java等语言而言,Python拥有非常独特的优势,通过极少的代码量就可以实现相同的功能,可以有效提升开发者的
Python基础练习--输出9*9乘法口诀表
def table(): for i in range(1,10): for j in range(1,i+1): print('{}x{}={}t'.format(j, i, i*j), end='') print()if __name__ == '__main
【2022】Centos7.4安装anaconda3(anaconda2022.11)
一、下载anaconda 如果你要将anaconda共享给同一主机的其他用户使用,不要用root用户安装anaconda,其他用户无法共享root用户的anaconda。我的服务器就我一个人使用,我还是
标识解析--载体
标识解析载体:分为:主动标识载体、被动标识载体。 主动标识载体:嵌入设备内部,承载标识编码、必要安全证书、算法、秘钥,具备联网通信功能,主动向标识解析服务节点或标识数
369问题网
免责声明:问题365网所有文字、图片、视频、音频等资料均来自互联网,不代表本站赞同其观点,内容仅代表作者本人意见,若因此产生任何纠纷作者本人负责,本站亦不为其版权负责! 如有问题,请联系我们
CopyRight©1999-2022 www.wt369.net/ All Right Reserved