Ubuntu14.04上安装pip的方法
在Ubuntu14.04上,通过sudo apt-get install python-pip下载的pip版本有些老,在使用时很可能出现下面的问题
root@ubt:~# pip 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_point 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
这是因为通过apt-get安装的pip版本太老了,老的pip版本依赖requests.compat.IncompleteRead,而在2.4.0版本的requests中已经移除了
requests.compat.IncompleteRead,解决方法是先卸载pip(命令为sudo apt-get remove python-pip),然后通过下面的方式重新下载安装
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate sudo python get-pip.py
安装完后,测试一下吧,发现不能识别pip这个命令,额,我也不知道怎么回事,解决办法是在/usr/bin目录下建一个软肋接,指向到/usr/local/bin/pip
njsqrt3@temp-test2:~$ pip -bash: /usr/bin/pip: No such file or directory # $PATH的值包含/usr/bin njsqrt3@temp-test2:~$ which pip /usr/local/bin/pip # $PATH的值包含/usr/local/bin njsqrt3@temp-test2:~$ njsqrt3@temp-test2:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games njsqrt3@temp-test2:~$
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。