龙空技术网

想重装python但有很多包怎么办?不要慌,教你如何快速重装

皛心 131

前言:

目前大家对“python和pythonw两个装一个就可以”大致比较重视,兄弟们都需要学习一些“python和pythonw两个装一个就可以”的相关资讯。那么小编同时在网摘上汇集了一些关于“python和pythonw两个装一个就可以””的相关文章,希望姐妹们能喜欢,同学们快快来了解一下吧!

安装python相信对学习python的朋友们来说肯定是小菜一碟。但是对于完全重装python时怎么把一大堆包快速安装好,很多朋友还是挺犯怵的,哇塞,pip list一屏都显示不完,怎么搞啊?

不要慌,跟着我一步步来搞定。

保存python包列表

pip list >list.txt

在cmd命令提示符输入以上命令,作用是将python所有的安装包列表输出到list.txt文件中。

重装以前一定要保存安装包列表。

处理list.txt文件

用notepad++打开刚刚的list.txt文件,去掉开头2行无用的信息,再转码成utf8,保存文件。

再写几行python脚本,代码如下:

import osos.chdir("D:/我的文档")  # 注意刚刚的list.txt所在路径,要保存到这里with open("list.txt", mode='r', encoding='utf8') as f1:    with open("list2.txt", mode='w', encoding='utf8') as f2:        for i in f1:            line = i.split()            f2.write(line[0] + ' ')

运行脚本,检查list2.txt内容,看看是不是符合要求。

我的list2.txt文件内容如下:

altgraph argon2-cffi asgiref async-generator attrs backcall bleach cffi colorama Cython decorator defusedxml Django entrypoints future ipykernel ipython ipython-genutils ipywidgets jedi Jinja2 jsonschema jupyter jupyter-client jupyter-console jupyter-core jupyterlab-pygments llvmlite MarkupSafe mistune nbclient nbconvert nbformat nest-asyncio notebook numba numpy packaging pandas pandocfilters parso pefile pickleshare pip pkuseg prometheus-client prompt-toolkit pycparser pygame Pygments pyinstaller pyinstaller-hooks-contrib pyparsing PyQt5 PyQt5-sip pyrsistent python-dateutil pytz pywin32 pywin32-ctypes pywinpty pyzmq qtconsole QtPy Send2Trash setuptools six sqlparse terminado testpath tornado traitlets wcwidth webencodings wheel widgetsnbextension

这么一大堆如果一行行手工装得忙活好一会时间呢!

将安装包列表文件加工成一行。

配置国内源

安装python首先要配置国内源,首先进入自己电脑的用户目录,我的是“C:\Users\40859\”,在该目录下创建pip目录,然后创建pip.ini文件(可以新建文本文件,然后改文件名)。

文件内容如下:

[global]index-url = [install]trusted-host=mirrors.aliyun.com
重装系统或python

这一步自己完成,这里不再赘述。

重装python环境

系统和python重装完成后,现在需要安装python环境。注意:安装python最后有提示去除单行命令字符数量限制,一定要勾选。

更新pip,命令如下:

python -m pip install --upgrade pip
更新setuptools,命令如下:
pip install --upgrade setuptools
急速安装python环境
pip install altgraph argon2-cffi asgiref async-generator attrs backcall bleach cffi colorama Cython decorator defusedxml Django entrypoints future ipykernel ipython ipython-genutils ipywidgets jedi Jinja2 jsonschema jupyter jupyter-client jupyter-console jupyter-core jupyterlab-pygments llvmlite MarkupSafe mistune nbclient nbconvert nbformat nest-asyncio notebook numba numpy packaging pandas pandocfilters parso pefile pickleshare pip pkuseg prometheus-client prompt-toolkit pycparser pygame Pygments pyinstaller pyinstaller-hooks-contrib pyparsing PyQt5 PyQt5-sip pyrsistent python-dateutil pytz pywin32 pywin32-ctypes pywinpty pyzmq qtconsole QtPy Send2Trash setuptools six sqlparse terminado testpath tornado traitlets wcwidth webencodings wheel widgetsnbextension

注意:pip install后面加个空格,再后面的内容是从list2.txt中全部复制粘贴过来的。

急速重装python环境!

标签: #python和pythonw两个装一个就可以 #vs2019如何安装pygame