学习了嵩天老师的python课程,自己试了下整个安装过程,觉得很棒,现把成功安装的过程展示出来。
#BatchInstall.py
import os
libs = {"numpy","matplotlib","pillow","sklearn","requests",\
"jieba","beautifulsoup4","wheel","networkx","sympy",\
"pyinstaller","django","flask","werobot","pyqt5",\
"pandas","pyopengl","pypdf2","docopt","pygame"}
try:
for lib in libs:
os.system("pip3 install "+lib)
print("Successful")
except:
print("Failed Somehow")
“numpy”,“matplotlib”,“pillow”,“sklearn”,“requests”,
“jieba”,“beautifulsoup4”,“wheel”,“networkx”,“sympy”,
“pyinstaller”,“django”,“flask”,“werobot”,“pyqt5”,
“pandas”,“pyopengl”,“pypdf2”,“docopt”,“pygame”
需要另加其他第三方库的话,直接在代码里面添加即可。注意名字。
下载BatchInstall文件
或者按后续的代码编辑python,保存文件名为BatchInstall
在终端改变当前操作路径为存放这个BathInstall.py的路径;我这里的路径是G:\pythonpractices\python入门。改成你的存放这个文件的路径即可。
然后列表中的第三方库都会一个个安装成功,用的时间取决于实际情况。估计需要一段比较长的时间。最后显示Successful,即为成功。
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (3.0.4)
有时也会提醒你更新当前python版本,不过应该不影响安装,不过每个安装包安装的时候都会红字提醒你,第三方库安装成功后再更新python版本即可。
输入对应的提示代码即可。