记录,转需。
1、导出系统python库
环境:windows
内置freeze,还有其他参数可借鉴:参考
1.1、导出系统中所有依赖库
pip freeze > requirements.txt
1.2、安装依赖库
pip install -r requirements.txt
最后会生成requirements.txt
2、导出项目库
需要pipreqs模块
2.安装pipreqs
pip install pipreqs
2.1导出依赖库
先cd到指定位置,在项目的当前路径输入:
pipreqs ./ --encoding=utf-8
3、【离线下载】指定路径下载模块(zip、wheel)
download参数,主要用于批量离线下载第三方模块zip、wheel
pip download -r requirements.txt -d /tmp
-r requirements.txt前文导出的requirements,自己手动写也行,不拘泥于是否pip生成,requirements.txt格式如下👇
/tmep 为指定下载的路径,自行替换。
Tips:可能存在no found file requirements.txt 不妨可以尝试cd到requirements.txt路径下,或者是 在指令中,指定requirements.txt的路径(尝试下😊
4、【离线安装】指定路径安装模块(zip\wheel
主要用于批量离线安装第三方模块zip、wheel
pip3 install --no-index --find-links=DIR -r requirements.txt --target=DIR
--find-links=DIR 的DIR为zip、wheel存放的位置
--target=DIR 的DIR 为指定到哪里安装,不指定会默认安装到python路径中。
推荐:python--批量离线安装python包_时代的病人的博客-CSDN博客_python批量安装第三方包
5、 【在线安装】指定下载至某个文件夹下
主要用于在线安装模块时,将模块安装到指定文件夹下。
pip install mysql --target 文件夹地址