# 使用 PIP 在 python 中安裝包
> 原文: [https://thepythonguru.com/installing-packages-in-python-using-pip](https://thepythonguru.com/installing-packages-in-python-using-pip)
* * *
于 2020 年 1 月 7 日更新
* * *
PIP 是一個包管理系統,用于從存儲庫安裝包。 您可以使用`pip`安裝 [http://pypi.python.org/pypi](http://pypi.python.org/pypi) 上可用的各種包。 PIP 與 php 中的作曲家非常相似。 PIP 是遞歸的首字母縮寫,代表 PIP 安裝包。
## 安裝 PIP
* * *
Python 2.7.9 及更高版本(python2 系列)和 Python 3.4 及更高版本(python 3 系列)已經帶有 pip。
要檢查您的 python 版本,您需要輸入以下命令:
```py
python ?-V
```
如果您的 python 版本不屬于上述任何版本,則需要手動安裝`pip`(請參見下面的鏈接)。
* [單擊此處以獲取 Windows 安裝說明](http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows)。
* [單擊此處以獲取 Linux 指南](https://pip.pypa.io/en/latest/installing.html)。
## 安裝包
* * *
假設您要安裝一個名為 [Requests](https://pypi.python.org/pypi/requests/2.7.0) 的包(用于發出 HTTP 請求)。 您需要發出以下命令。
```py
pip install requests # this will install latest request package
pip install requests==2.6.0 # this will install requests 2.6.0 package not the latest package
pip install requests>=2.6.0 # specify a minimum version if it's not available pip will install the latest version
```
**注意**:
`pip.exe`存儲在`C:\Python34\Scripts`下,因此您需要去那里安裝包。 或者,將整個路徑添加到`PATH`環境變量。 這樣,您可以從任何目錄訪問`pip`。
## 卸載包
* * *
要卸載包,請使用以下命令。
```py
pip uninstall package_name
```
## 升級包
* * *
```py
pip install --upgrade package_name
```
## 搜索包
* * *
```py
pip search "your query"
```
**注意**:
您無需在搜索字詞前后添加引號。
## 列出已安裝的包
* * *
```py
pip list
```
上面的命令將列出所有已安裝的包。
## 列出過時的已安裝包
* * *
```py
pip list --outdated
```
## 有關已安裝包的詳細信息
* * *
您可以使用以下命令來獲取有關已安裝包的信息,即包名稱,版本,位置,依賴項。
```py
pip show package_name
```
* * *
* * *
- 初級 Python
- python 入門
- 安裝 Python3
- 運行 python 程序
- 數據類型和變量
- Python 數字
- Python 字符串
- Python 列表
- Python 字典
- Python 元組
- 數據類型轉換
- Python 控制語句
- Python 函數
- Python 循環
- Python 數學函數
- Python 生成隨機數
- Python 文件處理
- Python 對象和類
- Python 運算符重載
- Python 繼承與多態
- Python 異常處理
- Python 模塊
- 高級 Python
- Python *args和**kwargs
- Python 生成器
- Python 正則表達式
- 使用 PIP 在 python 中安裝包
- Python virtualenv指南
- Python 遞歸函數
- __name__ == "__main__"是什么?
- Python Lambda 函數
- Python 字符串格式化
- Python 內置函數和方法
- Python abs()函數
- Python bin()函數
- Python id()函數
- Python map()函數
- Python zip()函數
- Python filter()函數
- Python reduce()函數
- Python sorted()函數
- Python enumerate()函數
- Python reversed()函數
- Python range()函數
- Python sum()函數
- Python max()函數
- Python min()函數
- Python eval()函數
- Python len()函數
- Python ord()函數
- Python chr()函數
- Python any()函數
- Python all()函數
- Python globals()函數
- Python locals()函數
- 數據庫訪問
- 安裝 Python MySQLdb
- 連接到數據庫
- MySQLdb 獲取結果
- 插入行
- 處理錯誤
- 使用fetchone()和fetchmany()獲取記錄
- 常見做法
- Python:如何讀取和寫入文件
- Python:如何讀取和寫入 CSV 文件
- 用 Python 讀寫 JSON
- 用 Python 轉儲對象