查找python项目依赖并生成requirements.txt

多人一块儿开发项目的时候老是要搭建环境和部署环境的,这个时候必须得有个python第三方包的list,通常都叫作requirements.txt。 若是一个项目使用时virtualenv环境,还好办 pip freeze 就能够解决,可是若是一个项目的依赖list没有维护,并且又是环境混用,那就很差整理。不过,这里推荐一个python模块pipreqs,能够自动根据源码生成 requirements.txt html

使用pip freeze生成requirements.txthtml5

pip freeze > requirements.txt

使用 pipreqspython

这个工具的好处是能够经过对项目目录的扫描,自动发现使用了那些类库,自动生成依赖清单。redis

缺点是可能会有些误差,须要检查并本身调整下。django

# pip install pipreqs

使用方式也比较简单

pipreqs ./

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.txtubuntu

chardet==2.0.1
colorama==0.2.5
configobj==4.7.2
Django==1.11.10
djangorestframework==3.7.7
gunicorn==19.7.1
html5lib==0.999
jieba==0.39
Landscape-Client==14.12
MySQL-python==1.2.3
numpy==1.14.0
PAM==0.4.2
pandas==0.22.0
Pillow==5.0.0
PyMySQL==0.8.0
pyOpenSSL==0.13
pyserial==2.6
python-apt===0.9.3.5ubuntu2
python-dateutil==2.6.1
python-debian===0.1.21-nmu2ubuntu2
python-igraph==0.6.5
pytz==2017.3
redis==2.10.6
requests==2.2.1
six==1.5.2
ssh-import-id==3.21
Twisted-Core==13.2.0
urllib3==1.7.1
zope.interface==4.0.5

原文网址:http://www.chenxm.cc/post/538...ssh

相关文章
相关标签/搜索