pipreqs คือ เป็นฟังก์ชั่นที่ใช้สร้างไฟล์ requirements ที่ใช้สำหรับเก็บการ import ของตัว module และ package ที่อยู่ใน library ที่ได้ทำการติดตั้งในโปรแกรมที่พัฒนาในภาษา Python ไฟล์ของ requirements จะมีสกุลไฟล์ .txt จะใช้เมื่อทำการนำโปรแกรมที่พัฒนาเสร็จเรียบร้อยแล้วนำใช้ เพื่อที่จะทำการติดตั้ง module ที่ใช้สำหรับโปรแกรม ซึ่งประโยชน์ของ pipreqs ก็คือตัวเป็นสร้าง ไฟล์ requirements เพื่อใช้เก็บ module ที่อยู่ใน library ของโปรแกรม เพื่อไปติดตั้งยังเครื่องอื่น
ขั้นตอนการใช้งาน
ทำการ install pipreqs ก่อน จะใช้คำสั่งดังนี้
โค้ด: เลือกทั้งหมด
$ pip install pipreqs
โค้ด: เลือกทั้งหมด
Usage:
pipreqs [options] <path>
Options:
--use-local Use ONLY local package info instead of querying PyPI
--pypi-server <url> Use custom PyPi server
--proxy <url> Use Proxy, parameter will be passed to requests library. You can also just set the
environments parameter in your terminal:
$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="https://10.10.1.10:1080"
--debug Print debug information
--ignore <dirs>... Ignore extra directories, each separated by a comma
--encoding <charset> Use encoding parameter for file open
--savepath <file> Save the list of requirements in the given file
--print Output the list of requirements in the standard output
--force Overwrite existing requirements.txt
--diff <file> Compare modules in requirements.txt to project imports.
--clean <file> Clean up requirements.txt by removing modules that are not imported in project.
โค้ด: เลือกทั้งหมด
$ pipreqs --use-local ./
อ้างอิง
https://www.pypi.org/project/pipreqs/
https://www.dev.to/bhupesh/pipreqs-automatically-generate-python-dependencies-30nl
https://www.github.com/bndr/pipreqs