介绍
pip是Python的包安装工具。类似npm客户端。python的包管理平台为:pypi
安装
如果
- 你使用的python是从官网下载的,且版本为: Python 2 >=2.7.9 或 Python 3 >=3.4
- 或者运行在用virtualenv或venv构建的虚拟环境
那么你只需要升级pip就可以了。
1. 查看是否已经安装。
$ python -m pip --version
# pip X.Y.Z from .../site-packages/pip (python X.Y)
2. 安装
a. 用easy_install安装
sudo easy_install pip
问题: Couldn’t find index page for ‘pip’ (maybe misspelled?) 原因 easy_install已经被废弃了
b. yum
sudo yum install python-pip
问题: sudo yum install python-pip ==原因:==yum没有安装
c. get-pip.py
# 先查看python的版本
python --version
# 得到版本为2.7.16
# 下载源码
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
# 在上面get-pip.py的目录下执行命令
python get-pip.py
# 查看是否安装成功
python -m pip --version
如果没有 setuptools和 wheel,get-pip.py执行过程中,都会安装。
d. 升级python到3.9已经自带了pip
brew install python
python3 --version
pip3 --version
3. 升级
python -m pip install -U pip
使用
1. pip装了哪些包?
pip3 list
2. pip安装的包在哪里
全部在当前工具执行路径下,如:/usr/local/lib/python3.9/site-packages
pip3 show
Name: bcrypt
Version: 3.2.0
Summary: Modern password hashing for your software and your servers
Home-page: https://github.com/pyca/bcrypt/
Author: The Python Cryptographic Authority developers
Author-email: cryptography-dev@python.org
License: Apache License, Version 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: six, cffi
Required-by: paramiko