python-3.x - 列出一个项目导入的所有python模块
问题描述
我在 python=3.6 上运行我的项目,我想列出这个项目/repo/目录中存在的 python 脚本导入的所有模块,以便我可以构建一个项目特定的需求文件以供将来使用。帮助我编写一个脚本来遍历目录树以列出模块或任何可用的 python 模块。
解决方案
I came across the pipreqs package, which generates a requirement.txt file based on the import statements of the project.
Installation:
pip install pipreqs
Usage:
pipreqs /path/to/project
pipreqs will automatically generate a requirements.txt file in root folder of your project.
Limitation: Pipreqs uses imports of projects to generate a requirements.txt file. So, it is very important to note that, pipreqs will not include the plugins required for specific projects. You need to add plugins information manually in a requirement.txt
推荐阅读
- java - 在超类中创建子类的实例
- swiftui - 删除在视图中的列表项上创建的空间 - SwiftUI
- entity-framework-6 - 无法加载文件或程序集“启动,Culture=neutral,PublicKeyToken=null”。系统找不到指定的文件:迁移错误
- c++ - 地图和文件 c++
- excel - 在受保护的工作表上运行宏
- django - 如何使用过滤器在django中按价格从低到高和从高到低对产品进行排序
- java - 无法解析主机“firebasestorage.googleapis.com”:没有与主机名关联的地址
- flutter - 在 Flutter 应用中创建 StreamProvider 需要更正
- c++ - 我想实现一个 BST 并尝试使用向量作为输入
- dataweave - 如何在 Mule 4 的对象数组中选择最后一个重复对象