드레스룸 시스템행거 인테리어

반응형

Anaconda(conda) 가상환경 설치

 

Anaconda는 패키지 관리와 디플로이를 단순케 할 목적으로 과학 계산을 위해 파이썬과 R 프로그래밍 언어의 자유-오픈 소스 배포판이다. 패키지 버전들은 패키지 관리 시스템 conda를 통해 관리된다.

라고 위키백과에 설명되어있다.

 

그냥 파이썬 버전과 패키지 관리 환경변수 등에 인하여 사용한다.

서버에 python 혹은 anaconda 둘 중 한 가지만 설치하기를 권장한다. 환경변수가 꼬이는 일이 생긴다고 한다.

하지만 여기서는 둘 다 설치해서 어떤 식으로 관리가 되는지 한번 봐보도록 하자~!

 

 

https://www.anaconda.com/products/individual

 

Individual Edition

🐍 Open Source Anaconda Individual Edition is the world’s most popular Python distribution platform with over 20 million users worldwide. You can trust in our long-term commitment to supporting the Anaconda open-source ecosystem, the platform of choice

www.anaconda.com

위 사이트에서 필요한 버전으로 다운로드하면 된다.

좀 더 다른 버전이 필요하다면 아래 링크를 통해 다운로드하면 된다.

https://repo.anaconda.com/archive/

 

 

 

다운로드 한 anaconda 버전을 아래와 같이 간단하게 설치해 주면 된다.

root@ubuntu:~# ./Anaconda3-2019.10-Linux-x86_64.sh

Welcome to Anaconda3 2019.10

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
Anaconda End User License Agreement
===================================
...
...

Do you accept the license terms? [yes|no]
[no] >>> yes
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] >>>

PREFIX=/root/anaconda3
Unpacking payload ...
...
...
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes

no change     /root/anaconda3/condabin/conda
no change     /root/anaconda3/bin/conda
no change     /root/anaconda3/bin/conda-env
no change     /root/anaconda3/bin/activate
no change     /root/anaconda3/bin/deactivate
no change     /root/anaconda3/etc/profile.d/conda.sh
no change     /root/anaconda3/etc/fish/conf.d/conda.fish
no change     /root/anaconda3/shell/condabin/Conda.psm1
no change     /root/anaconda3/shell/condabin/conda-hook.ps1
no change     /root/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change     /root/anaconda3/etc/profile.d/conda.csh
no change     /root/.bashrc
No action taken.
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!

===========================================================================

Anaconda and JetBrains are working together to bring you Anaconda-powered
environments tightly integrated in the PyCharm IDE.

PyCharm for Anaconda is available at:
https://www.anaconda.com/pycharm

 

설치 후 conda 관련 명령어를 아무 곳에서나 편하게 사용하기 위해 PATH 설정을 해주면 좋다.

# vim /etc/bash.bashrc

#### ADD ####
export PATH=/root/anaconda3/bin:$PATH
#############
# source /etc/bash.bashrc

 

 

기본적인 설치가 끝났으면 conda 명령어를 통한 파이선 환경을 만들어 보자.

 

root@ubuntu:~# conda create -n py3.6 python=3.6
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.7.12
  latest version: 4.8.3

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /root/anaconda3/envs/py3.6

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2020.1.1   |                0         125 KB
    certifi-2020.6.20          |           py36_0         156 KB
    ld_impl_linux-64-2.33.1    |       h53a641e_7         568 KB
    libedit-3.1.20191231       |       h7b6447c_0         167 KB
    libffi-3.3                 |       he6710b0_1          50 KB
    ncurses-6.2                |       he6710b0_1         817 KB
    openssl-1.1.1g             |       h7b6447c_0         2.5 MB
    pip-20.1.1                 |           py36_1         1.8 MB
    python-3.6.10              |       h7579374_2        29.7 MB
    readline-8.0               |       h7b6447c_0         356 KB
    setuptools-47.3.1          |           py36_0         514 KB
    sqlite-3.32.3              |       h62c20be_0         1.1 MB
    tk-8.6.10                  |       hbc83047_0         3.0 MB
    wheel-0.34.2               |           py36_0          51 KB
    xz-5.2.5                   |       h7b6447c_0         341 KB
    ------------------------------------------------------------
                                           Total:        41.2 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main
  ca-certificates    pkgs/main/linux-64::ca-certificates-2020.1.1-0
  certifi            pkgs/main/linux-64::certifi-2020.6.20-py36_0
  ld_impl_linux-64   pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7
  libedit            pkgs/main/linux-64::libedit-3.1.20191231-h7b6447c_0
  libffi             pkgs/main/linux-64::libffi-3.3-he6710b0_1
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  ncurses            pkgs/main/linux-64::ncurses-6.2-he6710b0_1
  openssl            pkgs/main/linux-64::openssl-1.1.1g-h7b6447c_0
  pip                pkgs/main/linux-64::pip-20.1.1-py36_1
  python             pkgs/main/linux-64::python-3.6.10-h7579374_2
  readline           pkgs/main/linux-64::readline-8.0-h7b6447c_0
  setuptools         pkgs/main/linux-64::setuptools-47.3.1-py36_0
  sqlite             pkgs/main/linux-64::sqlite-3.32.3-h62c20be_0
  tk                 pkgs/main/linux-64::tk-8.6.10-hbc83047_0
  wheel              pkgs/main/linux-64::wheel-0.34.2-py36_0
  xz                 pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
  zlib               pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)? y

Downloading and Extracting Packages
certifi-2020.6.20    | 156 KB    | #################################################################################################################################################################### | 100%
ca-certificates-2020 | 125 KB    | #################################################################################################################################################################### | 100%
xz-5.2.5             | 341 KB    | #################################################################################################################################################################### | 100%
libffi-3.3           | 50 KB     | #################################################################################################################################################################### | 100%
openssl-1.1.1g       | 2.5 MB    | #################################################################################################################################################################### | 100%
tk-8.6.10            | 3.0 MB    | #################################################################################################################################################################### | 100%
setuptools-47.3.1    | 514 KB    | #################################################################################################################################################################### | 100%
ld_impl_linux-64-2.3 | 568 KB    | #################################################################################################################################################################### | 100%
pip-20.1.1           | 1.8 MB    | #################################################################################################################################################################### | 100%
libedit-3.1.20191231 | 167 KB    | #################################################################################################################################################################### | 100%
python-3.6.10        | 29.7 MB   | #################################################################################################################################################################### | 100%
sqlite-3.32.3        | 1.1 MB    | #################################################################################################################################################################### | 100%
readline-8.0         | 356 KB    | #################################################################################################################################################################### | 100%
ncurses-6.2          | 817 KB    | #################################################################################################################################################################### | 100%
wheel-0.34.2         | 51 KB     | #################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate py3.6
#
# To deactivate an active environment, use
#
#     $ conda deactivate

 

위에 설치가 끝나니 아주 친절하게 사용법이 나와 있다.

방금 설치한 가상 환경에 activate와 deactivate

# conda activate py3.6
# conda deactivate

 

 

이제 conda가 어떠한 느낌인지 살짝 비교해보겠다. 

 

내가 사용하고 있는 local_server환경이다.

 

(base) root@ubuntu:~# python3
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
(base) root@ubuntu:~# pip3 list |wc -l
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
70

 

몇 개 test 하면서 설치를 했더니 python package가 너무 많아서 wc로 카운터만 해보았다.

 

자 이제 설치했던 가상 환경에 가서 확인해보겠다.

(base) root@ubuntu:~# conda activate py3.6
(py3.6) root@ubuntu:~# python
Python 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
(py3.6) root@ubuntu:~# pip3 list
Package    Version
---------- -------------------
certifi    2020.6.20
pip        20.1.1
setuptools 47.3.1.post20200622
wheel      0.34.2
(py3.6) root@ubuntu:~# conda deactivate
(base) root@ubuntu:~#

 

local서버와 다르게 python version 및 pip list 자체가 다르다.

 

이처럼 사용하는 파이썬 버전 및 패키지 관리를 위하여

 

여러 가지 파이썬 버전을 사용할 수 있다.

 

사용하는 파이썬 패키지는 requirements 파일로 작성 후 관리하면 더 편하게 사용할 수 있다.

반응형

이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band