Make requirements with only the packages you need
项目导入的 module 越多,导出的依赖库就越多,尤其是很多系统自带的库一并给导出来来了。
pip freeze 导出效果:
asgiref==3.3.4 async-timeout==4.0.3 certifi==2021.5.30 chardet==4.0.0 coreapi==2.3.3 coreschema==0.0.4 Django==3.2.3 django-admin-lightweight-date-hierarchy==1.1.0 django-comment-migrate==0.1.5 django-cors-headers==3.10.1 django-crontab==0.7.1 django-export-xls==0.1.1 django-filter==21.1 django-ranged-response==0.2.0 django-redis==5.2.0 django-restql==0.15.4 django-simple-captcha==0.5.14 django-simpleui==2022.7.29 django-timezone-field==4.2.3 djangorestframework==3.12.4 djangorestframework-simplejwt==5.1.0 drf-yasg==1.20.0 et-xmlfile==1.1.0 idna==2.10 inflection==0.5.1 itypes==1.2.0 Jinja2==3.0.1 MarkupSafe==2.0.1 openpyxl==3.0.9 packaging==20.9 paho-mqtt==1.6.1 Pillow==8.3.1 PyJWT==2.1.0 PyMySQL==1.0.2 pyparsing==2.4.7 pyPEG2==2.15.2 pypinyin==0.46.0 pypng==0.20220715.0 pytz==2021.1 qrcode==7.4.2 redis==5.0.8 requests==2.25.1 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 simplejson==3.18.4 six==1.16.0 smmap==4.0.0 sqlparse==0.4.1 typing-extensions==3.10.0.0 tzlocal==2.1 ua-parser==0.10.0 uritemplate==3.0.1 urllib3==1.26.6 user-agents==2.2.0 whitenoise==5.3.0 xlwt==1.3.0
pip-chill 导出效果:
django-admin-lightweight-date-hierarchy==1.1.0 django-comment-migrate==0.1.5 django-cors-headers==3.10.1 django-crontab==0.7.1 django-export-xls==0.1.1 django-filter==21.1 django-redis==5.2.0 django-restql==0.15.4 django-simple-captcha==0.5.14 django-simpleui==2022.7.29 django-timezone-field==4.2.3 djangorestframework-simplejwt==5.1.0 drf-yasg==1.20.0 encryptpy==1.0.5 openpyxl==3.0.9 paho-mqtt==1.6.1 pip-chill==1.0.3 pycryptodome==3.20.0 pymysql==1.0.2 pypinyin==0.46.0 qrcode==7.4.2 simplejson==3.18.4 tzlocal==2.1 user-agents==2.2.0 whitenoise==5.3.0
整体减掉了差不多一半多,同样在构建环境的时候也少了很多可能出问题的包,尤其是跨平台 install 的时候。
官方用法:
Suppose you have installed in your virtualenv a couple packages. When you run pip freeze, you'll get a list of all packages installed, with all dependencies. If one of the packages you installed ceases to depend on an already installed package, you have to manually remove it from the list. The list also makes no distinction about the packages you actually care about and packages your packages care about, making the requirements file bloated and, ultimately, inaccurate. On your terminal, run: $ pip-chill bandit==1.7.0 bumpversion==0.6.0 click==7.1.2 coverage==5.3.1 flake8==3.8.4 nose==1.3.7 pip-chill==1.0.1 pytest==6.2.1 ... Or, if you want it without version numbers: $ pip-chill --no-version bandit bumpversion click coverage flake8 nose pip-chill pytest ... Or, if you want it without pip-chill: $ pip-chill --no-chill bandit==1.7.0 bumpversion==0.6.0 click==7.1.2 coverage==5.3.1 flake8==3.8.4 nose==1.3.7 pytest==6.2.1 ... Or, if you want to list package dependencies too: $ pip-chill -v bandit==1.7.0 bumpversion==0.6.0 click==7.1.2 coverage==5.3.1 flake8==3.8.4 nose==1.3.7 pip-chill==1.0.1 pytest==6.2.1 sphinx==3.4.3 tox==3.21.1 twine==3.3.0 watchdog==1.0.2 # alabaster==0.7.12 # Installed as dependency for sphinx # appdirs==1.4.4 # Installed as dependency for virtualenv # attrs==20.3.0 # Installed as dependency for pytest # babel==2.9.0 # Installed as dependency for sphinx
17 comments
号外号外,灵妹妹更新啦,虽然看不懂
配图好评,快把我掰直了
别,直了多一伤心人。
why? 有什么说法
额,python你是专业的!
相当专业
所以凡事都不能荒废,以前我眼睛就是尺,看图识秀人模特——现在认不出了。
业精于勤而荒于稀
我废了,文字文字我看不懂,图片我也看不懂了。
不至于~~
这图,啧啧…
就说好不好看吧
来报道
已经习以为常,又是一篇看不懂的文章
看封面进来的,唉 ?怎么知识就进了脑袋…
整洁 哈哈 不过这和pip list 有啥区别呢
标题说了啊,更精简