Python) pipreqs - 특정 폴더안에 있는 파이썬 패키지를 requirements.txt 만들어주는 패키지

2021. 10. 13. 21:31분석 Python/Packages

728x90

유용하니까 사용하자.

몇 번 사용하였을 때 여러 장점이 있지만, pipereqs를 설치했지만 이 설치한 항목에 대해서는 requirements.txt 에 보이지가 않는다.

 

설치

pip install pipreqs

 

실행

경로를 설정하면 특정 경로에 패키지가 설치가 된다.

여기서는 예를 들어 /home/project/location/requirements.txt 로 있을 것이다.

pipreqs /home/project/location

 

이거 말고 poetry도 있는 것 같기는 한데, 그것은 파이썬 버전까지 해서 관리할 수 있는 것 같은데 절차가 좀 있어서 간단하게 할 때는 이게 좋아보인다.

 

옵션

해보다보면, 리눅스에서는 잘 되는데, 윈도우에 잘 안되는 경우가 있다.

내가 겪은 문제는 인코딩이 문제였고, 다음과 같이 파라미터를 보니 인코딩을 받는 부분이 있었다.

그래서 나는 인코딩을 utf-8 로 변경하니 잘 작동하였다.

 

# init function
encoding = args.get('--encoding')
extra_ignore_dirs = args.get('--ignore')
follow_links = not args.get('--no-follow-links')
pipreqs /home/project/location --encoding utf-8

 

https://github.com/bndr/pipreqs

 

GitHub - bndr/pipreqs: pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward. - GitHub - bndr/pipreqs: pipreqs - Generate pip requirements.txt ...

github.com

 

728x90