Poerty 가상환경 정리

star_is_mine·2022년 11월 4일
0

1. Poetry 공식 홈페이지

🧡(Link) "Poetry 공식 홈페이지 바로가기" : https://python-poetry.org/

2. Poetry 설치

curl -sSL https://install.python-poetry.org | python3 -
# Linux, macOS, Windows (WSL) - mac

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
# Windows (Powershell) - windows

3. Poetry 시작 명령어

poetry init
# 일부 블로그 글에서는 poetry 시작 명령어를 poetry new {project_name}
# 으로 알려주는 블로그 글도 봤는데. 이렇게 시작하면 불필요한? 파일들도 함께 생성된다. 
# 그러니 우리는 poetry init 명령어를 사용하자.

😢 주의사항] - poetry init 할때 상위 폴더에 한글로 된 경로가 존재하면.. 안되는것 같습니다.
이게 정확히 경로 문제인지 아니면 poetry.name 문제인지는 모르겠습니다. 그러나 아무튼 한글이... 포함되면 안됩니다. ㅠㅠ 한참 해맴

4. Poetry 실행 & 종료 명령어

poetry shell
# 실행 명령어

exit
# 종료 명령어

5. Poetry 주요 명령어

🧡(Link) "Poetry 주요 명령어 공식문서로 바로가서 보기"

poetry add django
# poetry 가상환경에 django 를 추가(설치) 하는 명령어

poetry remove django
# 반대로 삭제할 경우 사용하는 명령어 입니다. 

poetry update django
# poetry 가상환경에 이미 설치된 django 를 업데이트 하는 명령어

poetry remove django
# poetry 가상환경에 설치된 django 를 제거(삭제) 하는 명령어

6. Poetry 구체적인 사용예제 (Basic usage)

poetry init # poetry # 초기화 구체적인 가상환경에 대한 정보입력 과정 포함
poetry shell # poetry 가상환경으로 진입
poetry add django # 프로그램 개발에 필요한 프레임워크 등 설치

7. Poety 에서 pip freeze > requirements.txt 기능구현하기

참조한 블로그 링크

# pip 에서는 아래와 같이 명령하는 것을...
pip freeze > requirements.txt

# poety 에서는 아래와 같이 하면 됩니다. 
poetry export --without-hashes --format=requirements.txt > requirements.txt

8. poetry-add-requirements.txt 1.1.1 를 사용해보자

  • poetry 에서도 requirements.txt 를 이용해 쉽게 dependencie 를 설치 할 수 있다.

공식문서 링크텍스트

  • poetry-add-requirements.txt 1.1.1 설치(install)
pip install poetry-add-requirements.txt

poetry add poetry-add-requirements.txt

# usage 사용법 아래 
poetry-add-requirements.txt [-h] [-D] [-I] [-V] [requirements.txt files ...]

추가

# 위의 poetry-add-requirements.txt 1.1.1 라이브러리 없이도 본래 아래 명령어 입력 만으로도 설치가 가능해야 하는데... 간~ 혹 안될때는 위의 라이브러리를 사용하자. 
cat requirements.txt | xargs poetry add

위의 방법으로도 안 될때는 아래 참조


for item in $(cat requirements.txt); do poetry add "${item}"; done
https://stackoverflow.com/questions/62764148/how-to-import-requirements-txt-from-an-existing-project-using-poetry/72456245#72456245
profile
i have a dream and I will make my dreams come true.

0개의 댓글