conda

Published by onesixx on

https://dsaint31.tistory.com/category/Programming

conda search -c conda-forge 팩키지

condahttps://repo.anaconda.com/pkgs/를 default channel로 사용.

Channel 변경방법

❯ conda config --show channels
channels:
  - defaults
❯ conda config --add channels conda-forge && conda config --set channel_priority strict
❯ conda config --show channels
channels:
  - conda-forge
  - defaults

가상환경 생성

$ conda create -n fasta python=3.9.6                                        
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/onesixx/Library/r-miniconda/envs/fasta

  added / updated specs:
    - python=3.9


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    openssl-3.0.4              |       hfe4f2af_2         2.5 MB  conda-forge
    python-3.9.13              |hf8d34f4_0_cpython        12.8 MB  conda-forge
    sqlite-3.39.0              |       hd9f0692_0         1.8 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        17.1 MB

The following NEW packages will be INSTALLED:

  bzip2              conda-forge/osx-64::bzip2-1.0.8-h0d85af4_4
...
# 가상환경 복제하여 새로 생성
$ conda create -n [env-name] --clone [src-env-name]

$ conda create -n basenv --clone base
$ conda create -n pye12_4 --clone base

package 설치

채널추가

❯ conda config --show channels
channels:
  - defaults

❯ conda config --add channels conda-forge && conda config --set channel_priority strict
❯ conda config --show channels
channels:
  - conda-forge
  - defaults

설치 예>

$ conda install ipykernel 
uvicorn fastapi numpy pandas 
dash dash-bootstrap-components  

$ conda install -c conda-forge pandas-datareader

$ conda update --all

$ conda install --file requirements.txt

pip

$ conda install dash_admin_components

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:
$ pip install dash-admin-components

https://dailyheumsi.tistory.com/33

2. conda 내에서 pip install

pipanaconda3 에서 관리하고 있는 전역 pip에 들어가게 된다.
pip2local 내에 깔린 pip2 (python2 버전) 에 들어가게 된다.
pip3 : local 내에 깔린 pip3 (python3 버전) 에 들어가게 된다.

$ conda create -n py36 python=3.6  
...  
$ source activate py36  
$ (py36) ~

이렇게 진입한 콘다 가상환경 안에서 pip 명령어의 차이를 보면,

$ ls -l `which pip`
-rwxrwxr-x  1 heumsi  staff  244  3 26 18:27 /Users/heumsi/anaconda3/envs/py36/bin/pip
$ ls -l `which pip2`
lrwxr-xr-x  1 heumsi  admin  34  5 13 19:49 /usr/local/bin/pip2 -> ../Cellar/python@2/2.7.16/bin/pip2
$ ls -l `which pip3`
lrwxr-xr-x  1 heumsi  admin  33  3 19 20:49 /usr/local/bin/pip3 -> ../Cellar/python/3.7.2_2/bin/pip3

이번엔 pip 입력한 경우, 이전과 다르게 py36 환경의 pip에 깔리는 것을 알 수 있다.
한편, pip2 와 pip3 는 이전과 동일하게 local pip 에 들어가게되는 것을 알 수 있다.

즉, 가상환경 내에서만 패키지를 설치하려면, 그냥 pip install ~ 만 해야한다.
(혹여나 헷갈려서 pip3 install 로 하게되면, 그냥 전역 local에 깔리는 것이다 ;;;)

freeze requirement

$ pwd                                            
/Users/onesixx/my/git/sksk01

$ conda env export > freeze.yml

$ conda env create -f freeze.yml
$ pwd                                            
/Users/onesixx/my/git/sksk01

$ conda list --export > requirements.txt
$ conda list --explicit > requirements.txt 

$ conda install --name fasta --file requirements.txt
#$ conda create --name fasta --file requirements.txt
# This file may be used to create an environment using:
# $ conda create --name  --file 
# platform: osx-64
appnope=0.1.3=pyhd8ed1ab_0
asttokens=2.0.5=pyhd8ed1ab_0
backcall=0.2.0=pyh9f0ad1d_0
backports=1.0=py_2
backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
bzip2=1.0.8=h0d85af4_4
ca-certificates=2022.6.15=h033912b_0
debugpy=1.6.0=py39hfd1d529_0
# This file may be used to create an environment using:
# $ conda create --name  --file 
# platform: osx-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/osx-64/bzip2-1.0.8-h0d85af4_4.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/ca-certificates-2022.6.15-h033912b_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libcxx-14.0.6-hce7ea42_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libffi-3.4.2-h0d85af4_5.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libsodium-1.0.18-hbcb3906_1.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libzlib-1.2.12-hfe4f2af_1.tar.bz2

aaaaa

Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x