Python 주요명령어
Python 가상환경 설정 가이드
가상환경 설치
pip3 install virtualenv
virtualenv env
가상환경 실행
.\env\Scripts\activate.bat
패키지 목록 관리
pip freeze 명령어
pip freeze > requirements.txt
pip freeze를 사용하면 requirements.txt 파일에 패키지의 다운로드 주소가 @로 표시될 수 있습니다:
torch @ https://download.pytorch.org/whl/cu116/torch-1.13.1%2Bcu116-cp38-cp38-linux_x86_64.whl
torchaudio @ https://download.pytorch.org/whl/cu116/torchaudio-0.13.1%2Bcu116-cp38-cp38-linux_x86_64.whl
torchsummary==1.5.1
torchtext==0.14.1
torchvision @ https://download.pytorch.org/whl/cu116/torchvision-0.14.1%2Bcu116-cp38-cp38-linux_x86_64.whl
tqdm==4.64.1
pip list 명령어
pip list --format=freeze > requirements.txt
pip list를 사용하면 requirements.txt 파일에 패키지 이름과 버전만 기록됩니다:
torch==1.13.1+cu116
torchaudio==0.13.1+cu116
torchsummary==1.5.1
torchtext==0.14.1
torchvision==0.14.1+cu116
tqdm==4.64.1
pip install 명령어
requirements.txt에 명시된 모든 패키지를 설치합니다:
pip install -r requirements.txt
출처: CodeAngie
댓글
댓글 쓰기