怎么改utf8_想重装python但有很多包怎么办?不要慌,教你如何快速重装
安裝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:甥敳獲40859”,在該目錄下創建pip目錄,然后創建pip.ini文件(可以新建文本文件,然后改文件名)。
文件內容如下:
[global]index-url = https://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com重裝系統或python
這一步自己完成,這里不再贅述。
重裝python環境
系統和python重裝完成后,現在需要安裝python環境。注意:安裝python最后有提示去除單行命令字符數量限制,一定要勾選。
注意:pip install后面加個空格,再后面的內容是從list2.txt中全部復制粘貼過來的。
急速重裝python環境!
總結
以上是生活随笔為你收集整理的怎么改utf8_想重装python但有很多包怎么办?不要慌,教你如何快速重装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 斜面孔如何绘制_journal of n
- 下一篇: 查看node状态_第六章 无限可能,神器