标签:
使用环境: centos 6.6 and python 2.6
pip 包在epel 的yum 源中首先安装epel:
[root@kvm ~]# yum list|grep epel
epel-release.noarch 6-8 extras
[root@kvm ~]# yum install epel-release
然后安装python-pip
yum install python-pip
安装完成后,即可使用pip 命令
[root@kvm Flask]# pip -V
pip 1.3.1 from /usr/lib/python2.6/site-packages (python 2.6)
使用pip官方源发现被墙了,如下:
[root@kvm ~]# pip install virtualenv
Downloading/unpacking virtualenv
Could not fetch URL https://pypi.python.org/simple/virtualenv/: There was a problem confirming the ssl certificate: <urlopen error _ssl.c:477: The handshake operation timed out>
Will skip URL https://pypi.python.org/simple/virtualenv/ when looking for download links for virtualenv
Could not fetch URL https://pypi.python.org/simple/: There was a problem confirming the ssl certificate: <urlopen error _ssl.c:477: The handshake operation timed out>
Will skip URL https://pypi.python.org/simple/ when looking for download links for virtualenv
Cannot fetch index base URL https://pypi.python.org/simple/
Could not fetch URL https://pypi.python.org/simple/virtualenv/: There was a problem confirming the ssl certificate: <urlopen error _ssl.c:477: The handshake operation timed out>
Will skip URL https://pypi.python.org/simple/virtualenv/ when looking for download links for virtualenv
Could not find any downloads that satisfy the requirement virtualenv
No distributions at all found for virtualenv
Storing complete log in /root/.pip/pip.log
于是修改为国内豆瓣源: http://pypi.douban.com/simple/
查看文档: /usr/share/doc/python-pip-1.3.1/docs/configuration.txt 可得:
配置文件路径: * On Unix and Mac OS X the configuration file is: :file:`$HOME/.pip/pip.conf`
修改路径写法:
The names of the settings are derived from the long command line option, e.g.
if you want to use a different package index (``--index-url``) and set the
HTTP timeout (``--default-timeout``) to 60 seconds your config file would
look like this:
.. code-block:: ini
[global]
timeout = 60
index-url = http://download.zope.org/ppix
于是,写在/root/.pip/pip.conf 文件为:
[global]
timeout = 60
index-url = http://pypi.douban.com/simple/
测试:
[root@kvm Flask]# pip install virtualenv
Downloading/unpacking virtualenv
Downloading virtualenv-13.1.2.tar.gz (1.7MB): 1.7MB downloaded
Running setup.py egg_info for package virtualenv
warning: no previously-included files matching ‘*‘ found under directory ‘docs/_templates‘
warning: no previously-included files matching ‘*‘ found under directory ‘docs/_build‘
Installing collected packages: virtualenv
Running setup.py install for virtualenv
warning: no previously-included files matching ‘*‘ found under directory ‘docs/_templates‘
warning: no previously-included files matching ‘*‘ found under directory ‘docs/_build‘
Installing virtualenv script to /usr/bin
Installing virtualenv-2.6 script to /usr/bin
Successfully installed virtualenv
Cleaning up...
至此,pip已经可以正常使用
3、pip 参数说明
后续再补充,嘿嘿
标签:
原文地址:http://www.cnblogs.com/lowry-zhuang/p/5104690.html