# 簡介python
pip是一款包管理工具, 和apt, yum, brew功能相似bootstrap
# 安裝windows
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py python3 get-pip.py # 將pip3加入環境變量 vi /etc/profile export PATH=$PATH:/usr/local/bin #從新加載環境變量文件 source /etc/profile
# 使用工具
pip3 --help # 可查看幫助信息 pip3 --version 或 pip3 -V # 查看版本信息 which pip3 # 查看安裝位置
# 基本操做ui
安裝包this
pip3 install requests # 默認安裝最早版包 pip3 install requests==1.1.0 # 安裝指定版本包
批量安裝包阿里雲
pip install -r requirements.txt
requirements.txt 文件格式
Werkzeug==0.9.4
psycopg2==2.5.1
卸載包url
pip3 uninstall requests
更新某個包spa
pip3 install -U requests
或
pip3 install --upgrade requests
查看已安裝的全部包3d
pip3 list
顯示包文件
pip show --files requests
# 配置pip安裝源
國內源地址:
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
# mac
vi .pip/pip.conf # 打開配置文件 # 插入如下內容, 便可切換爲豆瓣源 [global] trusted-host=pypi.douban.com index-url=http://pypi.douban.com/simple
# windows在user目錄中建立一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容以下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
# 安裝某個包時 指定源
pip3 install requests -i http://pypi.douban.com/simple
# 安裝離線包
離線包下載地址 https://www.lfd.uci.edu/~gohlke/pythonlibs/
pip3 install xxxxxxx.whl # 安裝
# 安裝離線包, 報錯: xxx.whl is not a supported wheel on this platform
解決: 下載系統所支持的離線包便可
# 查看系統支持的安裝包
python3 -c "import pip._internal;print(pip._internal.pep425tags.get_supported())"
這些就是pip的基本操做, 若有錯誤, 歡迎交流