当前位置:网站首页>怎么自动安装pythn三方库
怎么自动安装pythn三方库
2022-07-05 18:19:00 【终端小蛙】
最近由于经常要换电脑,而换电脑之后同步自己之前的python环境,那么就搞了一个简单的解决方案
- 在原电脑上使用 pip list打印出安装的三方库
pip list
结果如下
- 在新电脑上安装完python环境后,跑下述脚本
import os import re def auto_install(fn:str): # 输入的fn为pip list中输出的格式 libPatten = re.compile("\s*(\w+)\s*([\d\.]+)") with open(fn,"r") as f: lines = f.readlines() for line in lines: libRe = libPatten.match(line) if libRe: libname = libRe.group(1) version = libRe.group(2) os.system("pip install "+libname +"=="+version) if __name__ == "__main__": fn = r"xxx.txt" auto_install(fn) - 等待自动跑脚本安装即可
好久没更新,哎,自创更新也烦呀
边栏推荐
- Multithreading (I) processes and threads
- 【在优麒麟上使用Electron开发桌面应】
- LeetCode 6109. 知道秘密的人数
- pytorch yolov5 训练自定义数据
- 《2022中国信创生态市场研究及选型评估报告》发布 华云数据入选信创IT基础设施主流厂商!
- LeetCode 6111. 螺旋矩阵 IV
- 开户注册股票炒股安全吗?有没有风险的?靠谱吗?
- 第十一届中国云计算标准和应用大会 | 华云数据成为全国信标委云计算标准工作组云迁移专题组副组长单位副组长单位
- [paddlepaddle] paddedetection face recognition custom data set
- The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
猜你喜欢
随机推荐
数值计算方法 Chapter8. 常微分方程的数值解
node_ Exporter memory usage is not displayed
Sophon CE社区版上线,免费Get轻量易用、高效智能的数据分析工具
Logical words in Articles
Privacy computing helps secure data circulation and sharing
星环科技重磅推出数据要素流通平台Transwarp Navier,助力企业实现隐私保护下的数据安全流通与协作
小林coding的内存管理章节
吴恩达团队2022机器学习课程,来啦
The origin of PTS, DTS and duration of audio and video packages
Introduction to Resampling
快速生成ipa包
写作写作写作写作
Le cours d'apprentissage de la machine 2022 de l'équipe Wunda arrive.
To solve the stubborn problem of Lake + warehouse hybrid architecture, xinghuan Technology launched an independent and controllable cloud native Lake warehouse integrated platform
The 11th China cloud computing standards and Applications Conference | cloud computing national standards and white paper series release, and Huayun data fully participated in the preparation
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
Sophon kg upgrade 3.1: break down barriers between data and liberate enterprise productivity
Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app
About Estimation with Cross-Validation
The 2022 China Xinchuang Ecological Market Research and model selection evaluation report released that Huayun data was selected as the mainstream manufacturer of Xinchuang IT infrastructure!








