41
pip freeze是魔鬼
source link: https://jiajunhuang.com/articles/2020_03_04-pip_list.md.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
pip freeze是魔鬼
很多用Python的项目,喜欢用 pip freeze > requirements.txt
来保存依赖,而不是手动维护文件,pip freeze
是魔鬼。
来看看一个项目依赖的简化版:
A B
/ \ / \
C D E
可以看到,依赖中可能会出现共同依赖。为啥说 pip freeze
是魔鬼呢?
- 可能会列入无关紧要的,或者非项目所需的依赖
- 把次级依赖的版本也写死了,当后来需要升级顶级依赖的时候,很难分辨需要升级哪些,因此不可维护
那么我建议的写法是什么样的呢?仅写入顶级依赖,比如:
flask==1.1.1
PyMySQL==0.9.3
SQLAlchemy==1.3.13
alembic==1.4.0
gevent==1.4.0
gunicorn==20.0.4
redis==3.4.1
这样虽然时间久了,次级依赖可能也会冲突,但是解决起来比上面说的要简单很多。
关注公众号,获得及时更新
Haskell TypeClass 笔记
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK