Anacoda에서 pip?
Anaconda 환경에선 기본적으로 conda install
을 이용해서 패키지를 설치한다.
하지만 원하는 버전의 패키지가 conda에 없는 경우가 있으면 pip install
을 사용해야 한다.
pip install
로 패키지를 설치하면 base 환경에 설치돼 가상 환경 분리가 안된다는 단점이 있다. 이럴 때 가상 환경에 먼저 pip
를 설치하고, pip install
을 적용하면 사용 중인 환경에만 패키지가 설치된다.
- 현재 가상 환경에
pip
설치 하기
conda install pip
- 가상 환경을 만들 때 부터
pip
를 설치하려면 다음과 같은 명령어를 사용하면 된다
conda create -n 이름 pip
예시
- 임의로 test라는 가상 환경을 만든 뒤 확인해보자.
(base) ~/anaconda3$ conda create -n test pip
(base) ~/anaconda3$ conda activate test
(test) ~/anaconda3$ pip list
Package Version
---------- -----------
certifi 2022.5.18.1
pip 21.2.4
setuptools 61.2.0
wheel 0.37.1
- torch 패키지가 test 환경 내 설치됐음을 확인할 수 있다.
(test) ~/anaconda3$ pip install torch
(test) ~/anaconda3$ pip list
Package Version
----------------- -----------
certifi 2022.5.18.1
pip 21.2.4
setuptools 61.2.0
torch 1.11.0
typing_extensions 4.2.0
wheel 0.37.1
- pip로 설치된 패키지가 매우 많아 앞 뒤로는 생략했지만 torch는 설치되지 않았음을 확인할 수 있다.
# 패키지가 너무 많아 일부는 생략했다.
(test) ~/anaconda3$ conda activate base
(base) ~/anaconda3$ pip list
Package Version
----------------- -----------
생략
tinycss 0.4
tldextract 3.2.0
toml 0.10.2
tomli 1.2.2
toolz 0.11.2
tornado 6.1
tqdm 4.64.0
traitlets 5.1.1
Twisted 22.2.0
생략
참고
Managing environments — conda 4.13.0.post13+775c20cb documentation
Conda removes the path name for the currently active environment from your system command. Note To simply return to the base environment, it's better to call conda activate with no environment specified, rather than to try to deactivate. If you run conda d
docs.conda.io