在Ubuntu14.04上,建議經過下面的方法安裝,這是一種通用的方法,也適用於Windows,固然在Windows下html
手動下載下來就好了python
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
sudo python get-pip.py
若是在Ubuntu14.04上你用sudo apt-get install python-pip下載安裝,在使用時有可能出現下面的問題git
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中已經移除了bootstrap
requests.compat.IncompleteRead,解決方法是先卸載pip(命令爲sudo apt-get remove python-pip),而後再用上面的方法從新安裝。bash
有時,還會遇到下面的SSL錯誤app
/tmp/tmpFlFxFp/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. /tmp/tmpFlFxFp/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
安裝下面幾個包python2.7
pip install pyopenssl ndg-httpsclient pyasn1
若是還有問題,再安裝下面的包測試
sudo apt-get install libffi-dev libssl-dev
安裝完後,測試一下吧,發現不能識別pip這個命令,額,我也不知道怎麼回事,解決辦法是在/usr/bin目錄下建一個軟連接,指向到/usr/local/bin/pipthis
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:~$