python之pip配置加速
Python的pip是一个包安装程序,用来安装和管理Python包。它是Python包索引(Python Package Index,PyPI)的命令行客户端,允许用户安装、升级、卸载和管理Python包
1.python-setup
1.1 download
https://www.python.org/downloads/source/
1.2 requirement
yum install -y gcc gcc-c++ make
1.3 untar && compiler
tar Jxf Python-2.7.13.tar.xz
./configure && make && make install
#查看python版本
python -V
1.4 setuptools-settup(基于zip包安装,非pip形式)
https://pypi.python.org/pypi/setuptools
unzip setuptools-32.3.0.zip
cd setuptools
python setup.py install
1.5 pip-setup
https://pypi.python.org/pypi/pip
tar zxf pip-9.0.1.tar.gz
python setup.py install
#基于包安装非源码包
# centos
yum install -y python-setuptools python-pip
# ubuntu
apt-get install python-setuptools python-pip
2.pip
2.1 pip help
# pip --help
Usage:
pip <command> [options]
Commands:
install 安装包.
uninstall 卸载包.
freeze 按着一定格式输出已安装包列表
list 列出已安装包.
show 显示包详细信息.
search 搜索包,类似yum里的search.
wheel Build wheels from your requirements.
zip 不推荐. Zip individual packages.
unzip 不推荐. Unzip individual packages.
bundle 不推荐. Create pybundles.
help 当前帮助.
General Options:
-h, --help 显示帮助.
-v, --verbose 更多的输出,最多可以使用3次
-V, --version 现实版本信息然后退出.
-q, --quiet 最少的输出.
--log-file <path> 覆盖的方式记录verbose错误日志,默认文件:/root/.pip/pip.log
--log <path> 不覆盖记录verbose输出的日志.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--timeout <sec> 连接超时时间 (默认15秒).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--cert <path> 证书.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new
version of pip is available for download. Implied with --no-
index.
2.2配置pip源
http://mirrors.aliyun.com/help/pypi
~/.pip/pip.conf
[global] index-url = http://mirrors.aliyun.com/pypi/simple/
[install] trusted-host=mirrors.aliyun.com
2.3测试安装
pip install requests
2.4安装本地的python编写的文件
pip install --cacahe-dir . shinken*.tar.gz
2.5常见安装命令
安装包:pip install package_name
卸载包:pip uninstall package_name
列出已安装的包:pip list
检查包是否已安装:pip show package_name
升级包:pip install --upgrade package_name
查找包:pip search search_term
显示包信息:pip info package_name
检查包的依赖关系:pip show --files package_name
pip一些有用的选项
--user:在用户目录下安装包,不使用管理员权限
pip install package_name --user //安装当前用户设定目录