Key Python Commands

Python Virtual Environment Setup Guide

Installing Virtual Environment

pip3 install virtualenv
virtualenv env

Activating Virtual Environment

.\env\Scripts\activate.bat

Managing Package List

pip freeze command

pip freeze > requirements.txt

When using pip freeze, package download URLs may be displayed with @ in the requirements.txt file:

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 command

pip list --format=freeze > requirements.txt

When using pip list, only package names and versions are recorded in the requirements.txt file:

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 command

Installs all packages specified in requirements.txt:

pip install -r requirements.txt

댓글

이 블로그의 인기 게시물

Anaconda-Python 환경 VSCode에서 사용하기

Python 웹 크롤링 - Scrapy 활용 파워볼 번호 수집(파일)