日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發布時間:2025/3/21 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 怎么改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,命令如下:
  • 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環境!

    總結

    以上是生活随笔為你收集整理的怎么改utf8_想重装python但有很多包怎么办?不要慌,教你如何快速重装的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。