https://devbull.xyz/python-create-environment/

<아나콘다로 가상환경 생성>

 

@ 가상환경 만들고 kernel 연결 후 juptyer notebook 실행 프로세스

1. 가상환경 생성 :  conda create -n 가상환경이름 python=버전

2. 가상환경 활성화 : conda activate 가상환경이름

3. 가상환경에 쥬피터 노트북 설치 : pip install jupyter notebook

4. 가상환경에 ipykernel 연결 :

  python -m ipykernel install --user --name 가상환경이름

5. juptyer notebook 실행 : jupyter notebook

 

@ conda 명령어 정리

- 가상환경 생성 :  conda create -n 가상환경이름 python=버전

- 가상환경 복사 : conda create --name 새환경이름 --clone 기존환경이름

- 가상환경 활성화 : conda activate 가상환경이름

- 가상환경 비활성화 : conda deactivate

- 가상환경 확인 : conda info --envs

- 라이브러리 저장 : pip freeze -> requirements.txt

- 가상환경 삭제 : conda remove --name 가상환경이름 --all

 

- 가상환경에 쥬피터 노트북 설치 : pip install jupyter notebook

- 가상환경에 kernel 연결 :

  pip install ipykernel   

  python -m ipykernel install --user --name 가상환경이름

 

@ jupyter notebook 화면에서 가상환경 커널 제거하는법

- 가상환경 커널 리스트 확인 : jupyter kernelspec list

- 커널 삭제 : jupyter kernelspec remove 커널이름

 

 

@ jupyter notebook에서 사용하는 python.exe 변경하기

- 현재 jupyter 에서 실행되는 python.exe 확인 

import sys
print(sys.executable)

- 현재 사용 가능한 python.exe 확인 : jupyter kernelspec list

- 가상환경의 python.exe 파일로 변경하기 : python -m ipykernel install --user --name [가상환경 이름] --display-name"[사용자가 설정하는 커널 이름]"

(예시) python -m ipykernel install --user --name cv_pytorch --display-name "cv_pytorch"

# python.exe 경로 추가
sys.path.append('C:/Users/runia/AppData/Roaming/jupyter/kernels/cv_pytorch')

 

@ 라이브러리 설치 경로 확인

- 전체 라이브러리 설치 경로 확인 : python -m site

- 특정 라이브러리 설치 경로 확인 :

import inspect

import tensorflow as tf

print(inspect.getfile(tf))   # tensorflow 라이브러리의 위치

 

@ 사용중인 아나콘다 가상환경

aitutor : 챗봇(openai, langchain 등)

cv : 컴퓨터 비젼

whisper : whisper ai

st_fastapi : streamlit with fast api

pandasai : 판다스AI

langchain310 : python 3.10 버전

 

------------------------------------------------------------------------------------------------------------------------------------------------

< venv로 가상환경 생성> (Runpod GPU)

 

@ venv로 가상환경 생성하기(ex. lora)

- 가상환경 생성 : python -m venv <가상환경이름>

- 가상환경 활성화 : source lora/bin/activate

- 가상환경에 kernel 연결

pip install ipykernel

python -m ipykernel install --user --name <가상환경이름>(lora)

 

@ venv로 가상환경 관리

- 가상환경 삭제 : rm -rf <가상환경이름>

 

'usually' 카테고리의 다른 글

colab  (0) 2021.10.02
엑셀이나 csv 를 직접 다룰 때 주의할 점  (0) 2021.10.01
import 기본 세팅  (0) 2021.09.28

+ Recent posts