Python | 如何使用pip升級所有Python軟件包?

While using Python as a programming language, it's a very common scenario to use a virtual environment and PIP, a package manager for python.

當使用Python作為編程語言時,使用虛擬環境PIP (Python的程序包管理器)是一種非常常見的情況。

It's a common practice to use a text file, named as "requirement.txt", which would be populated with the list of libraries used in the given application.

通常,使用文本文件“ requirement.txt” ,其中將填充給定應用程序中使用的庫的列表。

Generally, the developers maintain the version of the libraries in the "requirement.txt", as shown in the below example,

通常,開發人員在“ requirement.txt”中維護庫的版本,如以下示例所示,

    (venv) XXX:src XXX$ more requirements.txt 
numpy==1.17.2
requirements.txt (END)

Upgrading every library is a monotonous task, and hence the following commands can be used to upgrade all the packages in the venv (virtual environment) using PIP. We could either follow the below as a two-step process or also combine it to be a single line command.

升級每個庫都是一項單調的任務,因此,以下命令可用于使用PIP 升級 venv(虛擬環境)中的所有軟件包 。 我們可以按照以下兩個步驟進行操作,也可以將其組合為一個單行命令。

Approach 1:

方法1:

  1. Freeze all the libraries to a file called 'requirements.txt' (file name could be anything)

    將所有庫凍結到一個名為“ requirements.txt”的文件中(文件名可以是任何名稱)

    pip freeze > installed_library_list.txt
    
    
  2. Update all the libraries available in the file

    更新文件中所有可用的庫

    pip install -r installed_library_list.txt –upgrade
    
    

Approach 2:

方法二:

pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

The grep is to skip editable ("-e") package definitions, and the -n1 flag for xargs prevents stopping everything if updating one package fails.

grep將跳過可編輯的( “ -e” )軟件包定義,并且xargs-n1標志可防止在更新一個軟件包失敗時停止所有操作。

翻譯自: https://www.includehelp.com/python/upgrade-all-python-packages-with-pip.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541722.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541722.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541722.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

linux下enum類型占幾個字節,enum大小問題

問題描述板卡有兩個CPU,ARMMIPS,同時運行三個系統REE(linux) TEE(SierraTEE) SEE(TDS)。TEE跟SEE通過RPC進行通信,有enum成員的結構體信息傳遞會出錯,如下結構體:struct sTag {enum A;enum B;int C;enum D;};問題分析…

ASP.NET導出word實例

ASP.NET導出word實例 最近遇到一個題目就是如何在asp.net中將數據導出到word中,由于數據是動態的,所以需要在后臺拼出想要的的格式,翻遍了網頁找出了一個比較滿意的代碼,感謝那位高手。代碼如下: public void Download…

Java LocalDate類| toString()方法與示例

LocalDate類toString()方法 (LocalDate Class toString() method) toString() method is available in java.time package. toString()方法在java.time包中可用。 toString() method is used to represent this LocalDate as a String by using the standards ISO-8601 format.…

linux14.04 Apache,Ubuntu 14.04編譯安裝Apache

Ubuntu下編譯安裝apache需要預先編譯安裝多個依賴件,包括:apr, apr-util,pcre,zlib-devel,等,相當麻煩,記錄于此備查.由于Ubuntu系統默認安裝時沒有安裝C,所以也需要先安裝c編譯需要相關的組件。[注]apt-ca…

Android Jenkins自動化構建之路

install Jenkins 添加Jenkins的源(repository): sudo wget -O /etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key復制代碼yum install Jenkins復制代碼…

java 根據類名示例化類_Java即時類| plusMillis()方法與示例

java 根據類名示例化類即時類plusMillis()方法 (Instant Class plusMillis() method) plusMillis() method is available in java.time package. plusMillis()方法在java.time包中可用。 plusMillis() method is used to add the given duration in milliseconds to this Insta…

linux dd入門,Linux基礎知識:Linux中DD命令詳解

1.dd命令簡介功能:把指定的輸入文件拷貝到指定的輸出文件中,并且在拷貝過程中可以進行格式轉換。可以用該命令實現DOS下的diskcopy命令的作用。先用dd命令把軟盤上的數據寫成硬盤的一個寄存文件,再把這個寄存文件寫入第二張軟盤上&#xff0c…

CSS 字體(font)實例

1、設置文本字體 font-family:"Times New Roman",Georgia,Serif font-family:Arial,Verdana,Sans-serif 2、設置字體尺寸 font-size: 100% 3、設置字體風格 font-style:normal font-style:italic font-style:oblique 4、設置字體的異體 font-variant:normal text-var…

Java Duration類| 帶示例的compareTo()方法

持續時間類compareTo()方法 (Duration Class compareTo() method) compareTo() method is available in java.time package. compareTo()方法在java.time包中可用。 compareTo() method is used to compare this Duration object to the given object. compareTo()方法用于將此…

linux定時任務執行url,科技常識:linux定時任務訪問url實例

今天小編跟大家講解下有關linux定時任務訪問url實例 ,相信小伙伴們對這個話題應該也很關注吧,小編也收集到了有關linux定時任務訪問url實例 的相關資料,希望小伙伴會喜歡也能夠幫助大家。這次linux定時任務設置成功,也算是自己學習…

lcase和ucase_在SQL中使用UCASE(),LCASE()和MID()函數

lcase和ucaseUpper Case, Lower Case and MID functions are scalar functions which return a single value, based in the input value. 大寫,小寫和MID函數是標量函數,它們基于輸入值返回單個值。 As you all know sometimes different databases ha…

Maven的Settings.xml配置文件解釋

該配置用于單用戶配置和全局配置, 單用戶配置默認存放于 ${user.home}/.m2/目錄中. 全局配置默認存放于Maven安裝目錄下面的conf目錄中. 這兩個默認的位置都可以修改. <?xml version"1.0" encoding"UTF-8"?> <settings xmlns"http://m…

linux ntp手動授時,關于我校NTP授時服務的使用說明

校園網用戶&#xff1a;我中心于近期采購了GPS北斗授時服務設備&#xff0c;該設備可實現純GPS模式、純北斗模式和混合模式與衛星對時&#xff0c;同時實現對校內設備授時的功能。支持所有NTP協議的服務器、PC、嵌入式設備等&#xff0c;包括但不限于&#xff1a;Microsoft Win…

一串字符串轉換為ascii_將ASCII字符串(char [])轉換為C中的BYTE數組

一串字符串轉換為asciiGiven an ASCII string (char[]) and we have to convert it into BYTE array (BYTE[]) in C. 給定一個ASCII字符串(char [])&#xff0c;我們必須將其轉換為C語言中的BYTE數組(BYTE [])。 Logic: 邏輯&#xff1a; To convert an ASCII string to BYTE…

debugging Auto Layout:Logical Errors

Logical Errors邏輯錯誤 Logical errors are simply bugs. Somewhere, you have an assumption that is faulty. Perhaps it’s an assumption about how Auto Layout calculates the views’ frames. Perhaps it’s an assumption about the set of constraints that you’ve …

linux反序列化漏洞,思科多個產品Java反序列化漏洞(CVE-2015-6420)

思科多個產品Java反序列化漏洞(CVE-2015-6420)發布日期&#xff1a;2015-12-15更新日期&#xff1a;2015-12-17受影響系統&#xff1a;Cisco Unified ComputingCisco Voice and Unified Communications DevicesCisco Wireless描述&#xff1a;CVE(CAN) ID: CVE-2015-6420思科是…

密碼學替代技術_替代技術及其類型| 密碼學

密碼學替代技術As we already discussed what are the Substitution techniques and one of its type Ceasar Cipher? So we are not discussing it here for that please refer to Cryptography: CeasarCipher here: Cryptography: Caesar Cipher and its Python Implementat…

Flask+uwsgi+Nginx環境搭建

2019獨角獸企業重金招聘Python工程師標準>>> 開源軟件準備 需要的軟件列表&#xff1a; setuptools-33.1.1.zip Python-2.7.13.tgz pip-9.0.1.tar.gz nginx-1.10.3.tar.gz 軟件統一上傳到/usr/local/src/下&#xff0c;python是使用自己編譯的。Python安裝 先安裝以…

穿越迷宮c語言程序設計教程課后答案,實驗二 迷宮實驗.doc

#include #define ROW 11#define COLUMN 15typedef struct{ /*棧中的數據元素的類型定義*/int row; /*行下標*/int col; /*列下標*/int direction; /*下一步移動方向*/} DATA;Typedif struct node{ /* 棧類定義*/DATA data;Struct node *next;}LinkStack;Typedef struct{/*移動…

ofb模式_密碼學中的輸出反饋模式(OFB)

ofb模式This is an output feedback (OFB) mode is similar in structure to that of CFB in Cryptography. It is the output of the encryption function that is fed back to the shift register in OFB in the cryptography, whereas in CFB in the mode of blocks, the ci…