通过pip获取python环境下已安装的库——requirements方法
最近被环境问题搞怕了,特别是pyinstaller的打包问题,折腾了好久好久。为了避免下一次有这种库和库的冲突,可以采用这种方法。
获取环境中所有安装的包:
pip freeze >requirements.txt #在当前目录获取已经安装的python插件
获取当前项目需要的所有的包
安装pipreqs库
pip install pipreqs
然后执行
pipreqs ./ # 报错就执行下面这条
pipreqs ./ --encoding=utf-8
这个时候我们会在当前目录生成一个requiremengt.txt的文件。
我的如下
altgraph0.17
certifi2020.12.5
cffi1.14.4
chardet4.0.0
comtypes1.1.8
crypto1.4.1
cycler0.10.0
future0.18.2
idna2.10
iso86010.1.13
kiwisolver1.3.1
matplotlib3.1.1
Naked0.1.31
numpy1.19.5
pandas0.25.3
pefile2019.4.18
Pillow8.1.0
psutil5.8.0
PyAudio0.2.11
pycaw20181226
pycparser2.20
pycryptodome3.9.9
PyInstaller3.6
pyparsing2.4.7
pyserial3.5
python-dateutil2.8.1
pytz2020.5
pywin32300
pywin32-ctypes0.2.0
PyYAML5.3.1
requests2.25.1
scipy1.5.4
serial0.0.97
shellescape3.8.1
six1.15.0
sounddevice0.4.1
SoundFile0.10.3.post1
urllib31.26.4
WMI1.5.1
XlsxWriter1.3.7
这个是我项目能成功用pyinstaller打包exe并不报错的环境
那么,下次我在配置新环境时,可以直接用以下命令快速配置环境
pip install -r requirements.txt #在requirements.txt目录下运行
本文来自博客园,作者:JaxonYe,转载请注明原文链接:https://www.cnblogs.com/yechangxin/articles/16093635.html
侵权必究

浙公网安备 33010602011771号