2019年9月4日 星期三

使用 requirements.txt 在不同環境管理套件相依

最近剛入門 Python,遇到了在不同環境執行結果不同的問題,原來是套件版本不同導致,所以紀錄一下~
wiki - What is pip
pip is a de facto standard package-management system used to install and manage software packages written in Python
Python 常常會使用 PIP / PIP3 安裝很多套件(Library),但是要移植到其它機器或者要做環境 freeze (避免升級造成程式問題),很常見的作法就是使用 requirements.txt 來限定套件與版本 。

PIP 倒出現有環境套件

$ pip freeze > requirements.txt
openpyxl==2.6.3
boto3==1.9.220

PIP 安裝 requirements.txt 的套件

$ pip install -r requirements.txt

沒有留言:

張貼留言