软件包升级后,Pip 在 Ubuntu 14.4 上损坏
Pip broken on Ubuntu 14.4 after package upgrade
我试图在 EC2 ubuntu 14.4 实例上升级 python 请求包。这样做之后,没有抛出错误 I 运行
pip freeze
并得到:
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$ sudo apt-get remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
python-pip
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 479 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 58701 files and directories currently installed.)
Removing python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
ubuntu@ip-172-31-28-196:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
python-dev-all
The following NEW packages will be installed:
python-pip
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/97.7 kB of archives.
After this operation, 479 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 58626 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1_all.deb ...
Unpacking python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1) ...
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$ sudo apt-get --purge remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
python-pip*
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 479 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 58701 files and directories currently installed.)
Removing python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
ubuntu@ip-172-31-28-196:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
python-dev-all
The following NEW packages will be installed:
python-pip
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/97.7 kB of archives.
After this operation, 479 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 58626 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1_all.deb ...
Unpacking python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1) ...
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$
如您所见,我已尝试通过各种方式卸载并重新安装 pip,但均无济于事。我怎样才能让它重新工作?
编辑:
ubuntu@ip-172-31-28-196:~$ sudo python get-pip.py
The directory '/home/ubuntu/.cache/pip/log' or its parent directory is not owned by the current user
and the debug log has been disabled. Please check the permissions and owner of that directory. If e
xecuting pip with sudo, you may want the -H flag.
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current use
r and the cache has been disabled. Please check the permissions and owner of that directory. If exec
uting pip with sudo, you may want the -H flag.
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current use
r and the cache has been disabled. Please check the permissions and owner of that directory. If exec
uting pip with sudo, you may want the -H flag.
Collecting pip
Downloading pip-6.0.8-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 370kB/s
Installing collected packages: pip
Successfully installed pip-6.0.8
ubuntu@ip-172-31-28-196:~$ pip freeze
-bash: /usr/bin/pip: No such file or directory
ubuntu@ip-172-31-28-196:~$ sudo -H python get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages
ubuntu@ip-172-31-28-196:~$ sudo apt-get --purge remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python-pip' is not installed, so not removed
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
ubuntu@ip-172-31-28-196:~$ sudo -H python get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages
ubuntu@ip-172-31-28-196:~$ pip freeze
-bash: /usr/bin/pip: No such file or directory
apt-get
安装旧版本的 pip 可能会导致问题,完全删除 python-pip
与:
apt-get remove --purge python-pip
然后:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
使用 sudo 如果 需要
这应该适合你。请遵循这些简单的步骤。
步骤:1 sudo apt-get remove python-pip
步骤:2 sudo easy_install -U pip
将 return 一些像这样的地址:
安装 /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
步骤:3转到此link。
步骤:4 右击 >> 另存为.. 名称为 get-pip.py .
步骤:5 使用:cd 进入与您的get-pip.py文件相同的目录
步骤:6 使用:sudo python get-pip.py
或
步骤:7 使用:sudo apt-get install python-pip
我试图在 EC2 ubuntu 14.4 实例上升级 python 请求包。这样做之后,没有抛出错误 I 运行
pip freeze
并得到:
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$ sudo apt-get remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
python-pip
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 479 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 58701 files and directories currently installed.)
Removing python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
ubuntu@ip-172-31-28-196:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
python-dev-all
The following NEW packages will be installed:
python-pip
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/97.7 kB of archives.
After this operation, 479 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 58626 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1_all.deb ...
Unpacking python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1) ...
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$ sudo apt-get --purge remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
python-pip*
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 479 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 58701 files and directories currently installed.)
Removing python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
ubuntu@ip-172-31-28-196:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
python-dev-all
The following NEW packages will be installed:
python-pip
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/97.7 kB of archives.
After this operation, 479 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 58626 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1_all.deb ...
Unpacking python-pip (1.5.4-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1) ...
ubuntu@ip-172-31-28-196:~$ pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_poin
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
ubuntu@ip-172-31-28-196:~$
如您所见,我已尝试通过各种方式卸载并重新安装 pip,但均无济于事。我怎样才能让它重新工作?
编辑:
ubuntu@ip-172-31-28-196:~$ sudo python get-pip.py
The directory '/home/ubuntu/.cache/pip/log' or its parent directory is not owned by the current user
and the debug log has been disabled. Please check the permissions and owner of that directory. If e
xecuting pip with sudo, you may want the -H flag.
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current use
r and the cache has been disabled. Please check the permissions and owner of that directory. If exec
uting pip with sudo, you may want the -H flag.
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current use
r and the cache has been disabled. Please check the permissions and owner of that directory. If exec
uting pip with sudo, you may want the -H flag.
Collecting pip
Downloading pip-6.0.8-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 370kB/s
Installing collected packages: pip
Successfully installed pip-6.0.8
ubuntu@ip-172-31-28-196:~$ pip freeze
-bash: /usr/bin/pip: No such file or directory
ubuntu@ip-172-31-28-196:~$ sudo -H python get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages
ubuntu@ip-172-31-28-196:~$ sudo apt-get --purge remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python-pip' is not installed, so not removed
The following packages were automatically installed and are no longer required:
python-colorama python-distlib python-html5lib
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
ubuntu@ip-172-31-28-196:~$ sudo -H python get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages
ubuntu@ip-172-31-28-196:~$ pip freeze
-bash: /usr/bin/pip: No such file or directory
apt-get
安装旧版本的 pip 可能会导致问题,完全删除 python-pip
与:
apt-get remove --purge python-pip
然后:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
使用 sudo 如果 需要
这应该适合你。请遵循这些简单的步骤。
步骤:1 sudo apt-get remove python-pip
步骤:2 sudo easy_install -U pip
将 return 一些像这样的地址: 安装 /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
步骤:3转到此link。
步骤:4 右击 >> 另存为.. 名称为 get-pip.py .
步骤:5 使用:cd 进入与您的get-pip.py文件相同的目录
步骤:6 使用:sudo python get-pip.py
或
步骤:7 使用:sudo apt-get install python-pip