Anaconda 安装教程

简介

Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包管理与环境管理的功能,可以很方便地解决多版本python并存、切换以及各种第三方包安装问题。

官网简介

下载

官方下载地址

安装

上传

将Anaconda2-4.4.0-Linux-x86_64.sh上传到系统某文件夹,例如$HOME文件夹。

增加可执行权限

1
chmod +x Anaconda2-4.4.0-Linux-x86_64.sh

执行安装

执行如下命令开始安装
./Anaconda2-4.4.0-Linux-x86_64.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Welcome to Anaconda2 4.4.0 (by Continuum Analytics, Inc.)

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

# 输入回车

===================================
Anaconda End User License Agreement
===================================

Copyright 2017, Continuum Analytics, Inc.

All rights reserved under the 3-clause BSD License:

...
...
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
--More--

# 按多次空格进行翻页

kerberos (krb5, non-Windows platforms)
A network authentication protocol designed to provide strong authentication
for client/server applications by using secret-key cryptography.

cryptography
A Python library which exposes cryptographic recipes and primitives.

Do you approve the license terms? [yes|no]
>>>

# 输入yes,同意license

Anaconda2 will now be installed into this location:
$HOME/anaconda2

- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

[/home/zhenggang/anaconda2] >>>

# 输入安装路径,回车;如直接回车,则按默认路径安装

PREFIX=$HOME/anaconda2
installing: python-2.7.13-0 ...
installing: _license-1.1-py27_1 ...
installing: alabaster-0.7.10-py27_0 ...
installing: anaconda-client-1.6.3-py27_0 ...
...
...
installing: anaconda-4.4.0-np112py27_0 ...
installing: conda-4.3.21-py27_0 ...
installing: conda-env-2.6.0-0 ...
Python 2.7.13 :: Continuum Analytics, Inc.
creating default environment...
installation finished.
Do you wish the installer to prepend the Anaconda2 install location
to PATH in your $HOME/.bashrc ? [yes|no]
[no] >>>

# 输入yes,则将anaconda的path添加到~/.bashrc文件;
# 输入no,或者直接回车就不会了。

Prepending PATH=$HOME/anaconda2/bin to PATH in /vol-th/home/zhenggang/.bashrc
A backup will be made to: $HOME/.bashrc-anaconda2.bak


For this change to become active, you have to open a new terminal.

Thank you for installing Anaconda2!

Share your notebooks and packages on Anaconda Cloud!
Sign up for free: https://anaconda.org

配置使用

如果anaconda的PATH没有添加到~/.bashrc文件中,那么每次使用之前,请在当前终端执行如下命令:

1
export PATH=$HOME/anaconda2/bin:$PATH

如果已经添加到~/.bashrc中,则每次启动终端后会自动调用该anaconda环境。

执行python

在当前终端执行“python”命令,得到:

1
2
3
4
5
6
Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>

进阶

如果我们同时安装的了anaconda2和anaconda3,那么可以在~/.bashrc中添加如下命令:

1
2
alias py2='export PATH=$HOME/anaconda2/bin:$PATH'
alias py3='export PATH=$HOME/anaconda2/bin:$PATH'

当想使用python2的时候,就输入py2;同理,输入py3。

文章作者: mrzhenggang
文章链接: https://blog.mrzhenggang.com/anaconda-install/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Mr.ZhengGang
免费试用: 本站提供国家超级计算天津中心试用机会,详情请见 免费试用
微信打赏
支付宝打赏