pip: command not found 一系列报错


#安装python2.7版本

tar xvf Python-2.7.9.tar.xz

cd Python-2.7.9

./configure --prefix=/usr/bin/python2.7

make

make install


mv /usr/bin/python /usr/bin/python.bak

ln -s /usr/bin/python2.7/bin/python2.7 /usr/bin/python


问题1:yum安装报错

No module named yum

解决:

前面安装了python2.7,默认2.6。python 版本更改后,

/usr/bin/yum 文件需要更新  首行改为 #!/usr/bin/python2.6


问题2:pip command not found

[root@ Python-2.7.9]# pip install jinja2

-bash: pip: command not found

解决[root@ ~]#  yum -y install python-setuptools

      [root@ ~]#  easy_install pip


问题3:安装了python-setuptools之后,easy_install 又报错ImportError: No module named pkg_resources

[root@ ~]# easy_install pip

Traceback (most recent call last):

  File "/usr/bin/easy_install", line 5, in <module>

    from pkg_resources import load_entry_point

ImportError: No module named pkg_resources

解决:

[root@ ~]# curl https://bootstrap.pypa.io/ez_setup.py | python


问题4:easy_install pip 报错 The 'distribute==0.6.10' distribution was not found 

[root@ ~]# easy_install pip

Traceback (most recent call last):

  File "/usr/bin/easy_install", line 5, in <module>

    from pkg_resources import load_entry_point

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3019, in <module>

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3003, in _call_aside

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 655, in _build_master

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 963, in require

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 849, in resolve

pkg_resources.DistributionNotFound: The 'distribute==0.6.10' distribution was not found and is required by the application

解决:安装distribute

[root@ ~]# curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz

[root@ ~]# tar zxvf distribute-0.6.10.tar.gz

[root@ ~]# cd distribute-0.6.10

[root@ distribute-0.6.10]# python setup.py install


[root@ ~]# easy_install pip 成功

wKiom1k-VFjBk4dkAAISXT0NLP4545.jpg-wh_50


问题5:上图显示安装pip成功,但执行命令依然显示 command not found

[root@ ~]# pip install jinja2

-bash: pip: command not found

排查:

[root@ ~]# which pip

[root@~]# ls /usr/bin/pip

ls: 无法访问/usr/bin/pip: 没有那个文件或目录

解决:创建软连接:

[root@localhost ~]# ln -s /usr/bin/python2.7/bin/pip /usr/bin/pip


安装成功

[root@~]# pip install jinja2

Collecting jinja2

  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)

    100% |████████████████████████████████| 348kB 28kB/s 

Collecting MarkupSafe>=0.23 (from jinja2)

  Downloading MarkupSafe-1.0.tar.gz

Installing collected packages: MarkupSafe, jinja2

  Running setup.py install for MarkupSafe ... done

Successfully installed MarkupSafe-1.0 jinja2-2.9.6



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值