简体   繁体   English

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

[英]pip: Install error with python2.7 on ec2 AMI

After installing pip with get-pip.py 使用get-pip.py安装pip之后

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

I get this error when I try to check the installation with pip -V 当我尝试使用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

However this works with python2.6. 但是,这适用于python2.6。

Is there any reason why this happens that I am missing? 有什么原因使我失踪吗?

Edit: 编辑:

I am working with Amazon Linux AMI release 2016.03 which I guess is based on some RedHat distro 我正在使用Amazon Linux AMI版本2016.03,我猜它基于某些RedHat发行版

Try installing virtualenv for manage your versions independently: 尝试安装virtualenv以独立管理您的版本:

sudo apt-get install virtualenv

Create the virtual environment 创建虚拟环境

virtualenv newvenv

Run your new environment 运行新环境

source newvenv/bin/activate

Finally 最后

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

Probably you have an Ubuntu image. 可能您有一个Ubuntu映像。 You need to remove the system pip version before installing the new one. 在安装新版本之前,需要删除系统pip版本。

Do a apt-get remove python-pip before your commands and you will have a proper pip installed. 在命令之前执行apt-get删除python-pip,您将安装正确的pip。

For python3: apt-get remove python3-pip 对于python3:apt-get删除python3-pip

Same may apply for CentOS based onesbut you will have to do the same with yum instead of apt-get 基于CentOS的服务器可能同样适用,但是您必须对yum进行相同的操作,而不是apt-get

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM