两种方法:

虚拟环境:

使用 pip freeze

pip freeze > requirements.txt
# 这种方式推荐配合 virtualenv ,否则会把整个环境中的包都列出来。

只扫描项目目录

使用 pipreqs

这个工具的好处是可以通过对项目目录的扫描,自动发现使用了那些类库,自动生成依赖清单。缺点是可能会有些偏差,需要检查并自己调整下。

# 首先安装 pipreqs
# pip install pipreqs
# 安装位置在pip所在的目录下 # 使用方式也比较简单
pipreqs /var/www/project INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Starting new HTTPS connection (1): pypi.python.org
INFO: Successfully saved requirements file in ./requirements.txt cat requirements.txt Django == 1.6
django_redis == 4.3.0
redis == 2.10.5
django_redis_cache == 1.6.5
simplejson == 3.8.2
Twisted == 16.0.0
pycrypto == 2.6.1
ConcurrentLogHandler == 0.9.1
cx_Oracle == 5.2.1
ujson == 1.35

用法:

# pip install -r /var/www/project/requriements.txt
# 即可安装所有依赖

问题补充

在使用 pipreqs /var/www/project 时可能会遇见:

UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 776: illegal multibyte sequence

解决方法为:

在后面指定编码格式 pipreqs /var/www/project  --encoding=utf8

用法:pip install -r requriements.txt 即可安装所有依赖

最新文章

  1. 群福利:百度云管家-本地SVIP
  2. android.net.wifi的简单使用方法
  3. iOS-Auto property synthesis will not synthesize property 'delegate'; it will be implemented by its super
  4. 用纯原生js实现jquery的ready函数(两种实现)
  5. HDU 2821 Pusher
  6. LeetCode 343
  7. callerloc
  8. Educational Codeforces Round 9 -- A - Grandma Laura and Apples
  9. 2016年1月编程语言排行榜:Java荣获2015年度冠军
  10. C# 之【获取网页响应码200】
  11. 【木德木作杯楼市达人秀NO.28】南湖买房故事
  12. PHP去除空白字符
  13. Bloglines订阅Blog部落格RSS网摘 - Blog透视镜
  14. TV端:通过遥控器的点击实现图片的上下左右抖动的效果
  15. javaweb+spring 项目集成异常的处理
  16. linux 系统下IntelliJ IDEA的安装及使用
  17. Windows下ftp服务器搭建及配置
  18. 直接线性变换解法(DLT)用于标定相机
  19. 【心得体会】我考完MOS我明白了…
  20. [BZOJ4011][HNOI2015]落忆枫音-[dp乱搞+拓扑排序]

热门文章

  1. MacOS 修改主机名
  2. properties配置文件读取
  3. SAM4E单片机之旅——10、UART与MCK之PLL
  4. opencv中的子库
  5. Chef vs Puppet vs Ansible vs Saltstack: Which Works Best For You?
  6. 2.alert() 函数
  7. 安装MySQLdb出现的问题
  8. Looksery Cup 2015 C. The Game Of Parity —— 博弈
  9. 狂配Nginx
  10. GDP与股市市值