1.Anaconda软件:

conda是一个Python版本的管理器,可对系统中多个独立的Python环境(不同的版本和不同的包)分开管理。

推荐大家在清华的镜像站下载,速度可以,还可以选择适合自己的Pyhon版本。

清华大学开源镜像站:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

2.Anaconda和Miniconda的选择:

Anaconda:软件包大概500MB,安装后大概3-4G,base环境包括了conda管理器、Pyhon编译器、常用的包和Spyder IDE等,安装步骤和Miniconda类似。

    地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 

Miniconda:软件包大概50MB,安装后大概300MB,base环境选择只包括conda管理器和Python编译器,其他的包需要通过conda命令安装。

    地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/

在这里,我选择的是Miniconda,但Anaconda我也配置过,过程基本一致。

3.Miniconda版本选择:

py39_4.9.2:Python3.9的具体版本

Linux、MacOSX、Windows:软件的环境。

Ubuntu20结合自己的CPU Intel的64位处理器,选择x86_64的版本。

硬件架构拓展:ppc64,ppc64le,ARM,AMD,X86,i386,x86_64(AMD64),AArch64的概念 — https://blog.csdn.net/sunny_day_day/article/details/108714946。

4.Miniconda安装:

A:一般的下载保存目录都在用户目录下的Downloads文件夹,如下图。

B:运行Shell脚本,进行安装,命令如下图。

sudo bash Miniconda3-py39_4.9.2-Linux-x86_64.sh 
or
sudo bash ~/Downloads/Miniconda3-py39_4.9.2-Linux-x86_64.sh 

Enter回车:

一直回车略过说明信息,输入yes:

选择安装地址,回车即默认,我选择安装在/opt目录下,据习惯该目录存放第三方软件:

Do you wish the installer to initialize Miniconda3 by running conda init? —— 添加配置信息到 ~/.bashrc文件 yes:

If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false —— 如果不想默认进入conda环境,可执行下列语句: 

conda config --set auto_activate_base false

下列语句恢复,具体的说,若为true,打开终端会默认进入(base)环境,需要deactivate推出;若为false,打开终端需要acitivate环境。

conda config --set auto_activate_base true

重启终端后,未配置成功,手动添加地址至环境中:

首先,通过gedit文本编辑器打开环境配置文件:

sudo gedit /etc/profile

添加miniconda环境变量地址,注意换成自己的安装目录,不要丢了(:$PATH)原路径:

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

修改后注入环境

source /etc/profile

这里要注意:profile和bashrc文件的配置问题

1. bashrc是在系统启动后就会自动运行。

2. profile是在用户登录后才会运行。

3. 进行设置后,可运用source bashrc命令更新bashrc,也可运用source profile命令更新profile。

PS:通常我们修改bashrc,有些linux的发行版本不一定有profile这个文件

4. /etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。

期间我尝试了两种方法,发现source /etc/bash.bashrc后,可以进入环境,但很麻烦,查阅了资料后,发现二者的区别。

因此,我reboot了系统,完美解决。

5.conda的简单应用:

更换清华源,编辑coda的配置文件:

sudo gedit ./~.condarc
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

查看源,保证用的是镜像站提供的索引:

conda config --show-sources

 

 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐