Conda로 가상환경 만들기

    conda create -n [환경명] python=[버전]

    [root@nipa2019-0010 etc] conda create -n mrc python=3.6.8
    Collecting package metadata (current_repodata.json): done
    Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
    Collecting package metadata (repodata.json): done
    Solving environment: done
    
    
    ==> WARNING: A newer version of conda exists. <==
      current version: 4.8.2
      latest version: 4.8.3
    
    Please update conda by running
    
        $ conda update -n base -c defaults conda
    
    
    
    ## Package Plan ##
    
      environment location: /root/anaconda3/envs/mrc
    
      added / updated specs:
        - python=3.6.8
    
    
    The following packages will be downloaded:
    
        package                    |            build
        ---------------------------|-----------------
        certifi-2020.4.5.1         |           py36_0         155 KB
        ncurses-6.2                |       he6710b0_1         817 KB
        openssl-1.1.1g             |       h7b6447c_0         2.5 MB
        pip-20.0.2                 |           py36_3         1.7 MB
        python-3.6.8               |       h0371630_0        30.1 MB
        setuptools-47.1.1          |           py36_0         514 KB
        sqlite-3.31.1              |       h62c20be_1         1.1 MB
        wheel-0.34.2               |           py36_0          51 KB
        xz-5.2.5                   |       h7b6447c_0         341 KB
        ------------------------------------------------------------
                                               Total:        37.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.4.5.1-py36_0
      libedit            pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0
      libffi             pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4
      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.0.2-py36_3
      python             pkgs/main/linux-64::python-3.6.8-h0371630_0
      readline           pkgs/main/linux-64::readline-7.0-h7b6447c_5
      setuptools         pkgs/main/linux-64::setuptools-47.1.1-py36_0
      sqlite             pkgs/main/linux-64::sqlite-3.31.1-h62c20be_1
      tk                 pkgs/main/linux-64::tk-8.6.8-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
    openssl-1.1.1g       | 2.5 MB    | ###########################################################################
    python-3.6.8         | 30.1 MB   | ###########################################################################
    pip-20.0.2           | 1.7 MB    | ###########################################################################
    ncurses-6.2          | 817 KB    | ###########################################################################
    certifi-2020.4.5.1   | 155 KB    | ###########################################################################
    setuptools-47.1.1    | 514 KB    | ###########################################################################
    wheel-0.34.2         | 51 KB     | ###########################################################################
    xz-5.2.5             | 341 KB    | ###########################################################################
    sqlite-3.31.1        | 1.1 MB    | ###########################################################################
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    #
    # To activate this environment, use
    #
    #     $ conda activate mrc
    #
    # To deactivate an active environment, use
    #
    #     $ conda deactivate

    위와같이 python을 추가로 지정하면 해당 python 버전으로 환경을 생성한다.

     

    conda info --envs

    [root@nipa2019-0010 mrc] conda info --envs
    # conda environments:
    #
                             /home/centos/anaconda3
                             /home/centos/anaconda3/envs/caffe2_p27
                             /home/centos/anaconda3/envs/caffe_p27
                             /home/centos/anaconda3/envs/caffe_p35
                             /home/centos/anaconda3/envs/chainer_p27
                             /home/centos/anaconda3/envs/chainer_p36
                             /home/centos/anaconda3/envs/cntk_p27
                             /home/centos/anaconda3/envs/cntk_p36
                             /home/centos/anaconda3/envs/iota
                             /home/centos/anaconda3/envs/mxnet_p27
                             /home/centos/anaconda3/envs/mxnet_p36
                             /home/centos/anaconda3/envs/python2
                             /home/centos/anaconda3/envs/python3
                             /home/centos/anaconda3/envs/pytorch_p27
                             /home/centos/anaconda3/envs/pytorch_p36
                             /home/centos/anaconda3/envs/tensorflow2_p27
                             /home/centos/anaconda3/envs/tensorflow2_p36
                             /home/centos/anaconda3/envs/tensorflow_p27
                             /home/centos/anaconda3/envs/tensorflow_p36
                             /home/centos/anaconda3/envs/theano_p27
                             /home/centos/anaconda3/envs/theano_p36
    base                  *  /root/anaconda3
    mrc                      /root/anaconda3/envs/mrc
    

    mrc라는 이름의 가상환경이 생성된 것을 확인할 수 있다. 현재 base에 *가 표시되어 있는데 현재 환경이 base라는 의미이다. 

     

    source activate mrc

    [root@nipa2019-0010 mrc] source activate mrc
    (mrc) [root@nipa2019-0010 mrc] conda info --envs
    # conda environments:
    #
                             /home/centos/anaconda3
                             /home/centos/anaconda3/envs/caffe2_p27
                             /home/centos/anaconda3/envs/caffe_p27
                             /home/centos/anaconda3/envs/caffe_p35
                             /home/centos/anaconda3/envs/chainer_p27
                             /home/centos/anaconda3/envs/chainer_p36
                             /home/centos/anaconda3/envs/cntk_p27
                             /home/centos/anaconda3/envs/cntk_p36
                             /home/centos/anaconda3/envs/iota
                             /home/centos/anaconda3/envs/mxnet_p27
                             /home/centos/anaconda3/envs/mxnet_p36
                             /home/centos/anaconda3/envs/python2
                             /home/centos/anaconda3/envs/python3
                             /home/centos/anaconda3/envs/pytorch_p27
                             /home/centos/anaconda3/envs/pytorch_p36
                             /home/centos/anaconda3/envs/tensorflow2_p27
                             /home/centos/anaconda3/envs/tensorflow2_p36
                             /home/centos/anaconda3/envs/tensorflow_p27
                             /home/centos/anaconda3/envs/tensorflow_p36
                             /home/centos/anaconda3/envs/theano_p27
                             /home/centos/anaconda3/envs/theano_p36
    base                     /root/anaconda3
    mrc                   *  /root/anaconda3/envs/mrc

    윈도우 같은 경우 그냥 activate만 써도 가상환경을 쓸 수 있는데 centos에서는 앞에 source를 추가로 붙여야 한다. 두번째 줄에 (mrc)가 붙어 있는 상태로 가상환경 상태에 돌입된 것을 확인 할 수 있지만, 확인 사살로 conda info --envs를 입력해서 확인해보면 base가 아닌 mrc에 *가 되어 있는 것은 확인 할 수 있다.

    반응형

    댓글

    Designed by JB FACTORY