anaconda安装
anaconda软件包下载
点击标题链接即可进入anaconda官网的下载界面,然后下滑到最下面,看到如下界面:
老版本下载链接:https://repo.anaconda.com/archive/
命令行下载模式下可以使用如下方法获取到下载链接:
然后进入命令行输入:
wget $复制到的链接,如:
wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
即可下载文件
图形界面安装
图形界面的anaconda的安装比较简单,都是一些图形化的界面,在图形化安装的过程中一直点击下一步即可,但是有几点需要注意的地方:
(1)Windows版本安装的时候目标路径中不能含有空格,同时不能是“unicode”编码。
(2)在“Advanced Installation Options”中不要勾选“Add Anaconda to my PATH environment variable.”(“添加Anaconda至我的环境变量。”)。因为如果勾选,则将会影响其他程序的使用。如果使用Anaconda,则通过打开Anaconda Navigator或者在开始菜单中的“Anaconda Prompt”(类似macOS中的“终端”)中进行使用。
(3)除非你打算使用多个版本的Anaconda或者多个版本的Python,否则便勾选“Register Anaconda as my default Python 3.9”。
命令行安装
在使用wget命令下载好了anaconda之后,使用以下命令安装anaconda:
bash $下载好的文件名,例如:
bash Anaconda3-2022.10-Linux-x86_64.sh
出现以下说明,然后输入回车执行下一步:
Welcome to Anaconda3 2022.10
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
接着一直回车,等license结束之后会出现:
Do you accept the license terms? [yes|no]
[no] >>>
Please answer 'yes' or 'no':'
也没啥可不同意的,不同意不让用呀,输入yes回车
然后就让你选择安装路径了,默认是安装在/用户名/anaconda下面,如果不需要修改直接回车就可以,我一般默认安装。如果修改的话在下面输入路径,路径最好不要出现奇怪的符号。
Anaconda3 will now be installed into this location:
/用户名/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/用户名/anaconda3] >>>
然后就执行安装了,最后输出如下:
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.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
让你选择是否初始化,选择yes的话以后登录进系统默认就激活了conda环境,选择no的话默认不激活conda环境,需要手动激活才能使用conda命令。
这个意思默认是no的,我接下来分别介绍选择yes或者no的时候分别如何操作。
如果选择no,则输出的界面如下:
You have chosen to not have conda modify your shell scripts at all.
To activate conda's base environment in your current shell session:
eval "$(/root/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)"
To install conda's shell functions for easier access, first activate, then:
conda init
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Anaconda3!
===========================================================================
Working with Python and Jupyter is a breeze in DataSpell. It is an IDE
designed for exploratory data analysis and ML. Get better data insights
with DataSpell.
DataSpell for Anaconda is available at: https://www.anaconda.com/dataspell
上面的大致意思就是,你没有初始化conda,不能直接使用conda命令,需要使用绝对路径的方式运行conda,即指定conda的位置(刚刚安装的位置,如果是默认则是/用户名/anaconda3/bin/conda,不是默认的话则是你安装路径/bin/conda)。
即要想运行conda命令则需要如下命令运行:
/用户名/anaconda3/bin/conda [选项] [参数]
如:
/root/anaconda3/bin/conda info --envs
但是一直这样总是很麻烦,所以还不如直接就初始化环境,输入以下命令初始化:
/root/anaconda3/bin/conda init
所以总结下来之前的那个选项还是选yes好,省时省力。
取消进入base环境
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
最后这句话的意思是:如果不想要进入conda的base环境,使用以下命令取消:
conda config --set auto_activate_base false
这个base环境就是如果你进入系统最左边显示一个base,则你直接进入了base环境,运行python使用的是base环境的python,取消的话进入的是系统的python环境。
例如,没有取消base环境进入的是如下界面:
(base) 用户名@计算机名:/#
使用which python命令查看到的python位置是:
(base) 用户名@计算机名:/# which python
/用户名/anaconda3/bin/python
如果不取消还想退出base环境的话则使用如下命令即可退出:
conda deactivate
取消base环境进入的是如下界面:
用户名@计算机名:/#
使用which python命令查看到的python位置是:
用户名@计算机名:/# which python
/usr/bin/python
参考文献
[1] anaconda https://baike.baidu.com/item/anaconda/20407441
https://www.anaconda.com
[2] 初学 Python 者自学 Anaconda 的正确姿势是什么?https://zhuanlan.zhihu.com/p/32925500
[3] Anaconda介绍、安装及使用教程 https://zhuanlan.zhihu.com/p/32925500