갈루아의 반서재

728x90

Anaconda 를 설치하는 가장 좋은 방법은 최신판 Anaconda 설치 배시 스크립트를 다운로드 받아 검증 후 구동하는 것이다. 

Download Anaconda Distribution 에서 파이썬 3 용 최신 버전을 찾을 수 있다. 현재 포스팅 작성 시점 기준에서는 5.30 발표된 5.2 버전이 최신이다. 

임시(ephemeral) 아이템을 다운로드받을 /tmp 디렉토리로 변경하자. curl 을 이용하여 다음과 같이 최신판을 /tmp 디렉토리에 다운로드하자.

1
2
3
4
:/tmp# curl -O https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  621M  100  621M    0     0  12.0M      0  0:00:51  0:00:51 --:--:-- 11.2M
cs


이제 SHA-256 체크섬을 통해 다운로드 받은 파일을 검증해보자. 다음과 같이 sha256sum 명령어를 사용한다. 검증이 끝나면 다음과 같은 결과를 보게 될 것이다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
:/tmp# ls -al
total 636512
drwxrwxrwt  9 root root      4096 Jun 12 18:07 .
drwxr-xr-23 root root      4096 Jun 12 06:24 ..
-rw-r--r--  1 root root 651745206 Jun 12 18:08 Anaconda3-5.2.0-Linux-x86_64.sh
drwxrwxrwt  2 root root      4096 Jun  7 19:15 .font-unix
drwxrwxrwt  2 root root      4096 Jun  7 19:15 .ICE-unix
drwx------  3 root root      4096 Jun  7 19:15 systemd-private-cf2cb4abf7df4bcbbdc988b782780905-systemd-resolved.service-d6Yy6k
drwx------  3 root root      4096 Jun  7 19:15 systemd-private-cf2cb4abf7df4bcbbdc988b782780905-systemd-timesyncd.service-vAtkvJ
drwxrwxrwt  2 root root      4096 Jun  7 19:15 .Test-unix
drwxrwxrwt  2 root root      4096 Jun  7 19:15 .X11-unix
drwxrwxrwt  2 root root      4096 Jun  7 19:15 .XIM-unix
:/tmp# sha256sum Anaconda3-5.2.0-Linux-x86_64.sh
09f53738b0cd3bb96f5b1bac488e5528df9906be2480fe61df40e0e0d19e3d48  Anaconda3-5.2.0-Linux-x86_64.sh
cs


그러면 위의 결과를 Anaconda with Python 3 on 64-bit Linux  페이지의 결과와 비교해야 한다. 방금 우리는 Anaconda3-5.2.0-Linux-x86_64.sh 를 다운로드 받았으므로 해당 링크를 클릭한다.


해당 파일의 해쉬 값은 다음과 같다. 위에서 sha256sum 명령어를 사용한 검증 결과가 sha256 열의 값과 일치한다면 정상적으로 다운로드된 것이다. 이제 스크립트르르 실행하자. 

검증이 끝났으면 다음과 같이 스크립트를 실행합니다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
:/tmp# bash Anaconda3-5.2.0-Linux-x86_64.sh
 
Welcome to Anaconda3 5.2.0
 
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
Anaconda End User License Agreement
===================================
 
Copyright 2015, Anaconda, Inc.
cs


ENTER 를 눌러서 설치를 진행한다. 라이센스 사용 동의를 하고, 설치 위치를 확인한 후 ENTER 를 눌러 설치한다.


설치가 완료되면 다음과 같은 결과를 보게 된다. conda 명령어를 사용하기 위해 yes 를 타이핑한다.


설치가 끝나면 다음과 같은 결과를 보게 된다.

다음과 같이 아나콘다를 활성화시킨다. 설치를 검증하기 위해, 예를 들어  conda lis 명령어를 통해 설치된 패키지를 확인해보자. 

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
:/tmp# source ~/.bashrc
:/tmp# conda list
# packages in environment at /root/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he11e457_0
alabaster                 0.7.10           py36h306e16b_0
anaconda                  5.2.0                    py36_3
anaconda-client           1.6.14                   py36_0
anaconda-navigator        1.8.7                    py36_0
anaconda-project          0.8.2            py36h44fb852_0
asn1crypto                0.24.0                   py36_0
astroid                   1.6.3                    py36_0
astropy                   3.0.2            py36h3010b51_1
attrs                     18.1.0                   py36_0
babel                     2.5.3                    py36_0
backcall                  0.1.0                    py36_0
backports                 1.0              py36hfa02d7e_1
backports.shutil_get_terminal_size 1.0.0            py36hfea85ff_2
beautifulsoup4            4.6.0            py36h49b8c8c_1
bitarray                  0.8.1            py36h14c3975_1
bkcharts                  0.2              py36h735825a_0
blas                      1.0                         mkl
blaze                     0.11.3           py36h4e06776_0
bleach                    2.1.3                    py36_0
blosc                     1.14.3               hdbcaa40_0
bokeh                     0.12.16                  py36_0
boto                      2.48.0           py36h6e4cd66_1
bottleneck                1.2.1            py36haac1ea0_0
bzip2                     1.0.6                h14c3975_5
ca-certificates           2018.03.07                    0
cairo                     1.14.12              h7636065_2
certifi                   2018.4.16                py36_0
cffi                      1.11.5           py36h9745a5d_0
chardet                   3.0.4            py36h0f667ec_1
click                     6.7              py36h5253387_0
cloudpickle               0.5.3                    py36_0
clyent                    1.2.2            py36h7e57e65_1
colorama                  0.3.9            py36h489cec4_0
conda                     4.5.4                    py36_0
conda-build               3.10.5                   py36_0
conda-env                 2.6.0                h36134e3_1
conda-verify              2.0.0            py36h98955d8_0
contextlib2               0.5.5            py36h6c84a62_0
cryptography              2.2.2            py36h14c3975_0
curl                      7.60.0               h84994c4_0
cycler                    0.10.0           py36h93f1223_0
cython                    0.28.2           py36h14c3975_0
cytoolz                   0.9.0.1          py36h14c3975_0
dask                      0.17.5                   py36_0
dask-core                 0.17.5                   py36_0
datashape                 0.5.4            py36h3ad6b5c_0
dbus                      1.13.2               h714fa37_1
decorator                 4.3.0                    py36_0
distributed               1.21.8                   py36_0
docutils                  0.14             py36hb0f60f5_0
entrypoints               0.2.3            py36h1aec115_2
et_xmlfile                1.0.1            py36hd6bccc3_0
expat                     2.2.5                he0dffb1_0
fastcache                 1.0.2            py36h14c3975_2
filelock                  3.0.4                    py36_0
flask                     1.0.2                    py36_1
flask-cors                3.0.4                    py36_0
fontconfig                2.12.6               h49f89f6_0
freetype                  2.8                  hab7d2ae_1
get_terminal_size         1.0.0                haa9412d_0
gevent                    1.3.0            py36h14c3975_0
glib                      2.56.1               h000015b_0
glob2                     0.6              py36he249c77_0
gmp                       6.1.2                h6c8ec71_1
gmpy2                     2.0.8            py36hc8893dd_2
graphite2                 1.3.11               h16798f4_2
greenlet                  0.4.13           py36h14c3975_0
gst-plugins-base          1.14.0               hbbd80ab_1
gstreamer                 1.14.0               hb453b48_1
h5py                      2.7.1            py36ha1f6525_2
harfbuzz                  1.7.6                h5f0a787_1
hdf5                      1.10.2               hba1933b_1
heapdict                  1.0.0                    py36_2
html5lib                  1.0.1            py36h2f9c1c0_0
icu                       58.2                 h9c2bf20_1
idna                      2.6              py36h82fb2a8_1
imageio                   2.3.0                    py36_0
imagesize                 1.0.0                    py36_0
intel-openmp              2018.0.0                      8
ipykernel                 4.8.2                    py36_0
ipython                   6.4.0                    py36_0
ipython_genutils          0.2.0            py36hb52b0d5_0
ipywidgets                7.2.1                    py36_0
isort                     4.3.4                    py36_0
itsdangerous              0.24             py36h93cc618_1
jbig                      2.1                  hdba287a_0
jdcal                     1.4                      py36_0
jedi                      0.12.0                   py36_1
jinja2                    2.10             py36ha16c418_0
jpeg                      9b                   h024ee3a_2
jsonschema                2.6.0            py36h006f8b5_0
jupyter                   1.0.0                    py36_4
jupyter_client            5.2.3                    py36_0
jupyter_console           5.2.0            py36he59e554_1
jupyter_core              4.4.0            py36h7c827e3_0
jupyterlab                0.32.1                   py36_0
jupyterlab_launcher       0.10.5                   py36_0
kiwisolver                1.0.1            py36h764f252_0
lazy-object-proxy         1.3.1            py36h10fcdad_0
libcurl                   7.60.0               h1ad7b7a_0
libedit                   3.1.20170329         h6b74fdf_2
libffi                    3.2.1                hd88cf55_4
libgcc-ng                 7.2.0                hdf63c60_3
libgfortran-ng            7.2.0                hdf63c60_3
libpng                    1.6.34               hb9fc6fc_0
libsodium                 1.0.16               h1bed415_0
libssh2                   1.8.0                h9cfc8f7_4
libstdcxx-ng              7.2.0                hdf63c60_3
libtiff                   4.0.9                he85c1e1_1
libtool                   2.4.6                h544aabb_3
libxcb                    1.13                 h1bed415_1
libxml2                   2.9.8                h26e45fe_1
libxslt                   1.1.32               h1312cb7_0
llvmlite                  0.23.1           py36hdbcaa40_0
locket                    0.2.0            py36h787c0ad_1
lxml                      4.2.1            py36h23eabaa_0
lzo                       2.10                 h49e0be7_2
markupsafe                1.0              py36hd9260cd_1
matplotlib                2.2.2            py36h0e671d2_1
mccabe                    0.6.1            py36h5ad9710_1
mistune                   0.8.3            py36h14c3975_1
mkl                       2018.0.2                      1
mkl-service               1.1.2            py36h17a0993_4
mkl_fft                   1.0.1            py36h3010b51_0
mkl_random                1.0.1            py36h629b387_0
more-itertools            4.1.0                    py36_0
mpc                       1.0.3                hec55b23_5
mpfr                      3.1.5                h11a74b3_2
mpmath                    1.0.0            py36hfeacd6b_2
msgpack-python            0.5.6            py36h6bb024c_0
multipledispatch          0.5.0                    py36_0
navigator-updater         0.2.1                    py36_0
nbconvert                 5.3.1            py36hb41ffb7_0
nbformat                  4.4.0            py36h31c9010_0
ncurses                   6.1                  hf484d3e_0
networkx                  2.1                      py36_0
nltk                      3.3.0                    py36_0
nose                      1.3.7            py36hcdf7029_2
notebook                  5.5.0                    py36_0
numba                     0.38.0           py36h637b7d7_0
numexpr                   2.6.5            py36h7bf3b9c_0
numpy                     1.14.3           py36hcd700cb_1
numpy-base                1.14.3           py36h9be14a7_1
numpydoc                  0.8.0                    py36_0
odo                       0.5.1            py36h90ed295_0
olefile                   0.45.1                   py36_0
openpyxl                  2.5.3                    py36_0
openssl                   1.0.2o               h20670df_0
packaging                 17.1                     py36_0
pandas                    0.23.0           py36h637b7d7_0
pandoc                    1.19.2.1             hea2e7c5_1
pandocfilters             1.4.2            py36ha6701b7_1
pango                     1.41.0               hd475d92_0
parso                     0.2.0                    py36_0
partd                     0.3.8            py36h36fd896_0
patchelf                  0.9                  hf79760b_2
path.py                   11.0.1                   py36_0
pathlib2                  2.3.2                    py36_0
patsy                     0.5.0                    py36_0
pcre                      8.42                 h439df22_0
pep8                      1.7.1                    py36_0
pexpect                   4.5.0                    py36_0
pickleshare               0.7.4            py36h63277f8_0
pillow                    5.1.0            py36h3deb7b8_0
pip                       10.0.1                   py36_0
pixman                    0.34.0               hceecf20_3
pkginfo                   1.4.2                    py36_1
pluggy                    0.6.0            py36hb689045_0
ply                       3.11                     py36_0
prompt_toolkit            1.0.15           py36h17d85b1_0
psutil                    5.4.5            py36h14c3975_0
ptyprocess                0.5.2            py36h69acd42_0
py                        1.5.3                    py36_0
pycodestyle               2.4.0                    py36_0
pycosat                   0.6.3            py36h0a5515d_0
pycparser                 2.18             py36hf9f622e_1
pycrypto                  2.6.1            py36h14c3975_8
pycurl                    7.43.0.1         py36hb7f436b_0
pyflakes                  1.6.0            py36h7bd6a15_0
pygments                  2.2.0            py36h0d3125c_0
pylint                    1.8.4                    py36_0
pyodbc                    4.0.23           py36hf484d3e_0
pyopenssl                 18.0.0                   py36_0
pyparsing                 2.2.0            py36hee85983_1
pyqt                      5.9.2            py36h751905a_0
pysocks                   1.6.8                    py36_0
pytables                  3.4.3            py36h02b9ad4_2
pytest                    3.5.1                    py36_0
pytest-arraydiff          0.2                      py36_0
pytest-astropy            0.3.0                    py36_0
pytest-doctestplus        0.1.3                    py36_0
pytest-openfiles          0.3.0                    py36_0
pytest-remotedata         0.2.1                    py36_0
python                    3.6.5                hc3d631a_2
python-dateutil           2.7.3                    py36_0
pytz                      2018.4                   py36_0
pywavelets                0.5.2            py36he602eb0_0
pyyaml                    3.12             py36hafb9ca4_1
pyzmq                     17.0.0           py36h14c3975_0
qt                        5.9.5                h7e424d6_0
qtawesome                 0.4.4            py36h609ed8c_0
qtconsole                 4.3.1            py36h8f73b5b_0
qtpy                      1.4.1                    py36_0
readline                  7.0                  ha6073c6_4
requests                  2.18.4           py36he2e5f8d_1
rope                      0.10.7           py36h147e2ec_0
ruamel_yaml               0.15.35          py36h14c3975_1
scikit-image              0.13.1           py36h14c3975_1
scikit-learn              0.19.1           py36h7aa7ec6_0
scipy                     1.1.0            py36hfc37229_0
seaborn                   0.8.1            py36hfad7ec4_0
send2trash                1.5.0                    py36_0
setuptools                39.1.0                   py36_0
simplegeneric             0.8.1                    py36_2
singledispatch            3.4.0.3          py36h7a266c3_0
sip                       4.19.8           py36hf484d3e_0
six                       1.11.0           py36h372c433_1
snappy                    1.1.7                hbae5bb6_3
snowballstemmer           1.2.1            py36h6febd40_0
sortedcollections         0.6.1                    py36_0
sortedcontainers          1.5.10                   py36_0
sphinx                    1.7.4                    py36_0
sphinxcontrib             1.0              py36h6d0f590_1
sphinxcontrib-websupport  1.0.1            py36hb5cb234_1
spyder                    3.2.8                    py36_0
sqlalchemy                1.2.7            py36h6b74fdf_0
sqlite                    3.23.1               he433501_0
statsmodels               0.9.0            py36h3010b51_0
sympy                     1.1.1            py36hc6d1c1c_0
tblib                     1.3.2            py36h34cf8b6_0
terminado                 0.8.1                    py36_1
testpath                  0.3.1            py36h8cadb63_0
tk                        8.6.7                hc745277_3
toolz                     0.9.0                    py36_0
tornado                   5.0.2                    py36_0
traitlets                 4.3.2            py36h674d592_0
typing                    3.6.4                    py36_0
unicodecsv                0.14.1           py36ha668878_0
unixodbc                  2.3.6                h1bed415_0
urllib3                   1.22             py36hbe7ace6_0
wcwidth                   0.1.7            py36hdf4376a_0
webencodings              0.5.1            py36h800622e_1
werkzeug                  0.14.1                   py36_0
wheel                     0.31.1                   py36_0
widgetsnbextension        3.2.1                    py36_0
wrapt                     1.10.11          py36h28b7045_0
xlrd                      1.1.0            py36h1db9f0c_1
xlsxwriter                1.0.4                    py36_0
xlwt                      1.3.0            py36h7b00a1f_0
xz                        5.2.4                h14c3975_4
yaml                      0.1.7                had09818_2
zeromq                    4.2.5                h439df22_0
zict                      0.1.3            py36h3a3bf81_0
zlib                      1.2.11               ha838bed_2
cs


그럼 이제 Anaconda 환경 설정으로 넘어가자. Anaconda 가상 환경은 파이썬 버전이나 패키지별로 프로젝트 관리가 가능하도록 도와준다. 먼저 어떤 파이썬 버전이 사용가능한지부터 확인해보자. 아래와 같이 검색해보면 파이썬 2와 파이썬 3의 다양한 버전의 파이썬이 사용가능함을 알 수 있다.

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
:/tmp# conda search "^python$"
Loading channels: done
# Name                  Version           Build  Channel
python                    1.0.1               0  pkgs/free
python                    2.6.8               1  pkgs/free
python                    2.6.8               2  pkgs/free
python                    2.6.8               3  pkgs/free
python                    2.6.8               4  pkgs/free
python                    2.6.8               5  pkgs/free
python                    2.6.8               6  pkgs/free
python                    2.6.8               7  pkgs/free
python                    2.6.9               0  pkgs/free
python                    2.6.9               1  pkgs/free
python                    2.7.3               2  pkgs/free
python                    2.7.3               3  pkgs/free
python                    2.7.3               4  pkgs/free
python                    2.7.3               5  pkgs/free
python                    2.7.3               6  pkgs/free
python                    2.7.3               7  pkgs/free
python                    2.7.4               0  pkgs/free
python                    2.7.5               0  pkgs/free
python                    2.7.5               1  pkgs/free
python                    2.7.5               2  pkgs/free
python                    2.7.5               3  pkgs/free
python                    2.7.6               0  pkgs/free
python                    2.7.6               1  pkgs/free
python                    2.7.6               2  pkgs/free
python                    2.7.7               0  pkgs/free
python                    2.7.7               2  pkgs/free
python                    2.7.8               0  pkgs/free
python                    2.7.8               1  pkgs/free
python                    2.7.9               0  pkgs/free
python                    2.7.9               1  pkgs/free
python                    2.7.9               2  pkgs/free
python                    2.7.9               3  pkgs/free
python                    2.7.9              d1  pkgs/free
python                    2.7.9              d2  pkgs/free
python                   2.7.10               0  pkgs/free
python                   2.7.10               1  pkgs/free
python                   2.7.10               2  pkgs/free
python                   2.7.10              d0  pkgs/free
python                   2.7.11               0  pkgs/free
python                   2.7.11               5  pkgs/free
python                   2.7.11              d0  pkgs/free
python                   2.7.12               0  pkgs/free
python                   2.7.12               1  pkgs/free
python                   2.7.13               0  pkgs/free
python                   2.7.13     hac47a24_15  pkgs/main
python                   2.7.13     heccc3f1_16  pkgs/main
python                   2.7.13     hfff3488_13  pkgs/main
python                   2.7.14     h1571d57_29  pkgs/main
python                   2.7.14     h1571d57_30  pkgs/main
python                   2.7.14     h1571d57_31  pkgs/main
python                   2.7.14     h1aa7481_19  pkgs/main
python                   2.7.14     h435b27a_18  pkgs/main
python                   2.7.14     h89e7a4a_22  pkgs/main
python                   2.7.14     h91f54f5_26  pkgs/main
python                   2.7.14     h931c8b0_15  pkgs/main
python                   2.7.14     h9b67528_20  pkgs/main
python                   2.7.14     ha6fc286_23  pkgs/main
python                   2.7.14     hc2b0042_21  pkgs/main
python                   2.7.14     hdd48546_24  pkgs/main
python                   2.7.14     hf918d8d_16  pkgs/main
python                   2.7.15      h1571d57_0  pkgs/main
python                    3.3.0               2  pkgs/free
python                    3.3.0               3  pkgs/free
python                    3.3.0               4  pkgs/free
python                    3.3.0            pro0  pkgs/pro
python                    3.3.0            pro1  pkgs/pro
python                    3.3.1               0  pkgs/free
python                    3.3.2               0  pkgs/free
python                    3.3.2               1  pkgs/free
python                    3.3.3               0  pkgs/free
python                    3.3.4               0  pkgs/free
python                    3.3.5               0  pkgs/free
python                    3.3.5               1  pkgs/free
python                    3.3.5               2  pkgs/free
python                    3.3.5               3  pkgs/free
python                    3.3.5               4  pkgs/free
python                    3.4.0               0  pkgs/free
python                    3.4.1               0  pkgs/free
python                    3.4.1               1  pkgs/free
python                    3.4.1               2  pkgs/free
python                    3.4.1               3  pkgs/free
python                    3.4.1               4  pkgs/free
python                    3.4.2               0  pkgs/free
python                    3.4.3               0  pkgs/free
python                    3.4.3               1  pkgs/free
python                    3.4.3               2  pkgs/free
python                    3.4.4               0  pkgs/free
python                    3.4.4               5  pkgs/free
python                    3.4.5               0  pkgs/free
python                 3.5.0rc4               0  pkgs/free
python                    3.5.0               0  pkgs/free
python                    3.5.0               1  pkgs/free
python                    3.5.1               0  pkgs/free
python                    3.5.1               5  pkgs/free
python                    3.5.2               0  pkgs/free
python                    3.5.3               0  pkgs/free
python                    3.5.3               1  pkgs/free
python                    3.5.4               0  pkgs/free
python                    3.5.4     h00c01ad_19  pkgs/main
python                    3.5.4     h0b4c808_22  pkgs/main
python                    3.5.4     h2170f06_12  pkgs/main
python                    3.5.4     h3075507_18  pkgs/main
python                    3.5.4     h417fded_24  pkgs/main
python                    3.5.4     h56e0582_23  pkgs/main
python                    3.5.4     h72f0b78_15  pkgs/main
python                    3.5.4     hb43c6bb_21  pkgs/main
python                    3.5.4     hc053d89_14  pkgs/main
python                    3.5.4     hc3d631a_27  pkgs/main
python                    3.5.4     he2c66cf_20  pkgs/main
python                    3.5.5      hc3d631a_0  pkgs/main
python                    3.5.5      hc3d631a_1  pkgs/main
python                    3.5.5      hc3d631a_3  pkgs/main
python                    3.5.5      hc3d631a_4  pkgs/main
python                    3.6.0               0  pkgs/free
python                    3.6.1               0  pkgs/free
python                    3.6.1               2  pkgs/free
python                    3.6.2               0  pkgs/free
python                    3.6.2     h02fb82a_12  pkgs/main
python                    3.6.2     h0b30769_14  pkgs/main
python                    3.6.2     h33255ae_18  pkgs/main
python                    3.6.2     hca45abc_19  pkgs/main
python                    3.6.2     hdfe5801_15  pkgs/main
python                    3.6.3      h0ef2715_3  pkgs/main
python                    3.6.3      h1284df2_4  pkgs/main
python                    3.6.3      h6c0c0dc_5  pkgs/main
python                    3.6.3      hc9025b9_1  pkgs/main
python                    3.6.3      hcad60d5_0  pkgs/main
python                    3.6.3      hefd0734_2  pkgs/main
python                    3.6.4      hc3d631a_0  pkgs/main
python                    3.6.4      hc3d631a_1  pkgs/main
python                    3.6.4      hc3d631a_3  pkgs/main
python                    3.6.5      hc3d631a_0  pkgs/main
python                    3.6.5      hc3d631a_1  pkgs/main
python                    3.6.5      hc3d631a_2  pkgs/main
cs


그러면 최신 파이썬 3 버전을 사용하여 가상 환경을 구성해보자. 지금 구성하는 환경을 예를 들어 redsparrow 라고 명명하면 다음과 같이 구성이 가능하다. 그러면 어떤 패키지가 다운로드되는지 확인할 수 있다. 

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
:/tmp# conda create --name redsparrow python=3
Solving environment: done
 
## Package Plan ##
 
  environment location: /root/anaconda3/envs/my_conda
 
  added / updated specs:
    - python=3
 
 
The following packages will be downloaded:
 
    package                    |            build
    ---------------------------|-----------------
    setuptools-39.2.0          |           py36_0         551 KB
 
The following NEW packages will be INSTALLED:
 
    ca-certificates: 2018.03.07-0
    certifi:         2018.4.16-py36_0
    libedit:         3.1.20170329-h6b74fdf_2
    libffi:          3.2.1-hd88cf55_4
    libgcc-ng:       7.2.0-hdf63c60_3
    libstdcxx-ng:    7.2.0-hdf63c60_3
    ncurses:         6.1-hf484d3e_0
    openssl:         1.0.2o-h20670df_0
    pip:             10.0.1-py36_0
    python:          3.6.5-hc3d631a_2
    readline:        7.0-ha6073c6_4
    setuptools:      39.2.0-py36_0
    sqlite:          3.23.1-he433501_0
    tk:              8.6.7-hc745277_3
    wheel:           0.31.1-py36_0
    xz:              5.2.4-h14c3975_4
    zlib:            1.2.11-ha838bed_2
 
Proceed ([y]/n)?
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
Downloading and Extracting Packages
setuptools-39.2.0    |  551 KB | ########################################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate redsparrow
#
# To deactivate an active environment, use:
# > source deactivate
#
cs


구성된 환경은 다음과 같이 활성화시킬 수 있다. 활성화되고 나면 가상환경 이름이 앞 부분에 붙는 것을 확인할 수 있다. 

1
2
3
:/tmp# source activate my_conda
(redsparrow) :/tmp#
 
cs


해당 환경에서 어떤 버전의 파이썬이 사용되고 있는지는 다음과 같이 확인활 수 있다.

1
2
(redsparrow) fukaerii@server:/$ python --version
Python 3.6.5 :: Anaconda, Inc.
cs


비활성화는 다음과 같이 가능하다.

1
2
3
4
 
(redsparrow) :/tmp# source deactivate
:/tmp#
 
cs


여기서 source 대신 . 을 입력해도 같은 결과를 얻을 수 있다.

1
2
3
4
(redsparrow) fukaerii@server:/$ . deactivate
fukaerii@server:/$
fukaerii@server:/$ . activate redsparrow
(redsparrow) fukaerii@server:/$
cs


3이 아니라 3.5와 같이 구체적인 파이썬 버전을 인수로 쓸 수도 있다.
1
fukaerii@server:/$ conda create -n my_env35 python=3.5
cs


3.5.1 에서 3.5.2 로 업데이트하는 것처럼 같은 브랜치 내에서 파이썬 버전을 다음과 같이 업데이트할 수 있다.

1
2
3
4
(redsparrow) fukaerii@133-130-107-97:/$ conda update python
Solving environment: done
 
# All requested packages already installed.
cs


구성되어 있는 가상환경 목록은 다음과 같이 확인할 수 있다.

1
2
3
4
5
(redsparrow) fukaerii@server:/$ conda info --envs
# conda environments:
#
base                     /home/fukaerii/anaconda3
redsparrow            *  /home/fukaerii/anaconda3/envs/redsparrow
cs


여기서 *는 현재 활성화된 환경을 나타낸다.

아래 패키지는 기본적으로 각각의 환경에 설치된다.

  • openssl

  • pip

  • python

  • readline

  • setuptools

  • sqlite

  • tk

  • wheel

  • xz

  • zlib


예를 들어 numpy 와 같이 추가적으로 필요한 패키지는 다음과 같이 설치한다. 

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
 
fukaerii@server:/$ conda install --name redsparrow numpy
Solving environment: done
 
## Package Plan ##
 
  environment location: /home/fukaerii/anaconda3/envs/redsparrow
 
  added / updated specs:
    - numpy
 
 
The following packages will be downloaded:
 
    package                    |            build
    ---------------------------|-----------------
    numpy-base-1.14.5          |   py36hdbf6ddf_0         4.1 MB
    numpy-1.14.5               |   py36hcd700cb_0          94 KB
    mkl-2018.0.3               |                1       198.7 MB
    intel-openmp-2018.0.3      |                0         705 KB
    ------------------------------------------------------------
                                           Total:       203.6 MB
 
The following NEW packages will be INSTALLED:
 
    blas:           1.0-mkl
    intel-openmp:   2018.0.3-0
    libgfortran-ng: 7.2.0-hdf63c60_3
    mkl:            2018.0.3-1
    mkl_fft:        1.0.1-py36h3010b51_0
    mkl_random:     1.0.1-py36h629b387_0
    numpy:          1.14.5-py36hcd700cb_0
    numpy-base:     1.14.5-py36hdbf6ddf_0
 
Proceed ([y]/n)? y
 
 
Downloading and Extracting Packages
intel-openmp-2018.0. |  705 KB | ############################################### | 100%
numpy-base-1.14.5    |  4.1 MB | ############################################### | 100%
mkl-2018.0.3         | 198.7 MB | ############################################## | 100%
numpy-1.14.5         |   94 KB | ############################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
cs


물론 아나콘다 설치 단계에서 아래와 같이 numpy 패키지를 같이 설치할 수도 있다.

1
2
 
fukaerii@server:/$ conda create --name redsparrow python=3 numpy
cs


해당 가상환경을 더 이상 사용하지 않아 삭제가 필요한 경우 다음과 같이 하면 된다. 

1
2
 
fukaerii@server:/$ conda remove --name redsparrow --all
cs


이와 관련해 자세한 내용은 다음 링크에서 확인가능하다. 

https://www.digitalocean.com/community/tutorials/how-to-install-the-anaconda-python-distribution-on-ubuntu-16-04


728x90