pip:在ec2 AMI上使用python2.7安装错误

时间:2016-05-27 14:05:34

标签: python amazon-ec2 pip

用get-pip.py

安装pip后
 wget https://bootstrap.pypa.io/get-pip.py
 python get-pip.py

当我尝试使用pip -V

检查安装时出现此错误
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 637, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 650, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 829, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application

然而,这适用于python2.6。

为什么会发生这种情况我有什么理由失踪?

编辑:

我正在使用Amazon Linux AMI发布2016.03,我猜这是基于一些RedHat发行版

2 个答案:

答案 0 :(得分:3)

尝试安装virtualenv以独立管理您的版本:

sudo apt-get install virtualenv

创建虚拟环境

virtualenv newvenv

运行新环境

source newvenv/bin/activate

最后

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

答案 1 :(得分:0)

可能你有一个Ubuntu图像。在安装新版本之前,您需要删除系统点版本。

在命令之前执行apt-get remove python-pip,你将安装一个合适的pip。

对于python3:apt-get remove python3-pip

同样适用于基于CentOS的那些但你必须用yum代替apt-get