pycharm依赖管理(不要用pip freeze)

在使用python虚拟环境时,可以使用requirements.txt来管理当前项目的依赖。

注意,不要用 pip freeze > requirements.txt 这个命令,因为它会引入很多无关的包。

可以使用 pipreqs ./ --encoding=utf-8

./ 表示当前项目的目录,--encoding=utf-8 是为了避免报错(编码相关)

Note Why to use pipreqs? Because pip freeze will collect all dependencies from the environments. While pipreqs will collect requirements used only in the current project!

pipreqs 生成的依赖就是你在项目中 import 的,但是可能会有遗漏(需要手动补全)

pycharm 自带的 sync 的原理和 pipreqs一致

下载包时 pip install -r requirements.txt 即可

可以使用 下面的命令来展示当前项目的依赖树:

pipdeptree --python D:\XXXX\venv\Scripts\python.exe

bash 复制代码
colorlog==6.8.0
└── colorama [required: Any, installed: 0.4.6]
concurrent-log==1.0.1
└── portalocker [required: >=1.5.2, installed: 2.8.2]
    └── pywin32 [required: >=226, installed: 306]
grpcio==1.31.0
└── six [required: >=1.5.2, installed: 1.16.0]
influxdb==5.3.0
├── msgpack [required: ==0.6.1, installed: 0.6.1]
├── python-dateutil [required: >=2.6.0, installed: 2.8.2]
│   └── six [required: >=1.5, installed: 1.16.0]
├── pytz [required: Any, installed: 2023.3.post1]
├── requests [required: >=2.17.0, installed: 2.31.0]
│   ├── certifi [required: >=2017.4.17, installed: 2023.11.17]
│   ├── charset-normalizer [required: >=2,<4, installed: 3.3.2]
│   ├── idna [required: >=2.5,<4, installed: 3.6]
│   └── urllib3 [required: >=1.21.1,<3, installed: 2.1.0]
└── six [required: >=1.10.0, installed: 1.16.0]
pandas==1.0.5
├── numpy [required: >=1.13.3, installed: 1.20.0]
├── python-dateutil [required: >=2.6.1, installed: 2.8.2]
│   └── six [required: >=1.5, installed: 1.16.0]
└── pytz [required: >=2017.2, installed: 2023.3.post1]
pip==22.3.1
protobuf==3.20.2
psutil==5.9.3
pyarrow==2.0.0
└── numpy [required: >=1.14, installed: 1.20.0]
pymysql-pool==0.3.7
└── PyMySQL [required: >=0.7.10, installed: 1.1.0]
redis==3.5.3
setuptools==65.5.1
wheel==0.38.4
相关推荐
Java 码农24 分钟前
Centos7 maven 安装
java·python·centos·maven
倔强青铜三1 小时前
苦练Python第63天:零基础玩转TOML配置读写,tomllib模块实战
人工智能·python·面试
浔川python社1 小时前
《网络爬虫技术规范与应用指南系列》(xc—3):合规实操与场景落地
python
B站计算机毕业设计之家2 小时前
智慧交通项目:Python+YOLOv8 实时交通标志系统 深度学习实战(TT100K+PySide6 源码+文档)✅
人工智能·python·深度学习·yolo·计算机视觉·智慧交通·交通标志
IT森林里的程序猿2 小时前
基于机器学习方法的网球比赛胜负趋势预测
python·机器学习·django
正牌强哥2 小时前
Futures_ML——机器学习在期货量化交易中的应用与实践
人工智能·python·机器学习·ai·交易·akshare
倔强青铜三2 小时前
苦练Python第62天:零基础玩转CSV文件读写,csv模块实战
人工智能·python·面试
郝学胜-神的一滴2 小时前
Effective Python 第43条:自定义容器类型为什么应该从 `collections.abc` 继承?
开发语言·python
银行数字化转型导师坚鹏3 小时前
如何设计优秀的企业微信私域运营实战培训方案
大数据·python·企业微信
jerryinwuhan3 小时前
最短路径问题总结
开发语言·人工智能·python