Debian Wheezy provides an ancient version of pip utility for installing Python packages. To put it very simply, it does not work anymore as it is not using HTTPS protocol, but fortunately this issue can be quickly fixed.
Debian version.
$ lsb_release -a
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.11 (wheezy) Release: 7.11 Codename: wheezy
Python version (unfortunately Debian Wheezy does not provide at least 2.7.9 version).
$ python --version
Python 2.7.3
Install python-pip package. alternatively you can use get-pip.py Python script to install pip and downgrade it afterwards.
$ sudo apt-get install python-pip
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: binutils build-essential bzip2 cpp cpp-4.7 dpkg-dev fakeroot file g++ g++-4.7 gcc gcc-4.7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libclass-isa-perl libdpkg-perl libexpat1 libfile-fcntllock-perl libgdbm3 libgmp10 libgomp1 libitm1 libmagic1 libmpc2 libmpfr4 libquadmath0 libsqlite3-0 libstdc++6-4.7-dev libswitch-perl libtimedate-perl linux-libc-dev make manpages manpages-dev mime-support patch perl perl-modules python python-minimal python-pkg-resources python-setuptools python2.6 python2.6-minimal python2.7 python2.7-minimal Suggested packages: binutils-doc bzip2-doc cpp-doc gcc-4.7-locales debian-keyring g++-multilib g++-4.7-multilib gcc-4.7-doc libstdc++6-4.7-dbg gcc-multilib autoconf automake1.9 libtool flex bison gdb gcc-doc gcc-4.7-multilib libmudflap0-4.7-dev libgcc1-dbg libgomp1-dbg libitm1-dbg libquadmath0-dbg libmudflap0-dbg libcloog-ppl0 libppl-c2 libppl7 binutils-gold glibc-doc libstdc++6-4.7-doc make-doc man-browser ed diffutils-doc perl-doc libterm-readline-gnu-perl libterm-readline-perl-perl libpod-plainer-perl python-doc python-tk python-distribute python-distribute-doc python2.6-doc binfmt-support python2.7-doc Recommended packages: python-dev-all The following NEW packages will be installed: binutils build-essential bzip2 cpp cpp-4.7 dpkg-dev fakeroot file g++ g++-4.7 gcc gcc-4.7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libclass-isa-perl libdpkg-perl libexpat1 libfile-fcntllock-perl libgdbm3 libgmp10 libgomp1 libitm1 libmagic1 libmpc2 libmpfr4 libquadmath0 libsqlite3-0 libstdc++6-4.7-dev libswitch-perl libtimedate-perl linux-libc-dev make manpages manpages-dev mime-support patch perl perl-modules python python-minimal python-pip python-pkg-resources python-setuptools python2.6 python2.6-minimal python2.7 python2.7-minimal 0 upgraded, 50 newly installed, 0 to remove and 0 not upgraded. Need to get 57.0 MB of archives. After this operation, 165 MB of additional disk space will be used. Do you want to continue [Y/n]? [...] Setting up python-setuptools (0.6.24-1) ... Setting up python-pip (1.1-3) ... Setting up libswitch-perl (2.16-2) ... Setting up perl-modules (5.14.2-21+deb7u5) ... Setting up perl (5.14.2-21+deb7u5) ... update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode Setting up libstdc++6-4.7-dev (4.7.2-5) ... Setting up g++-4.7 (4.7.2-5) ... Setting up g++ (4:4.7.2-1) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode Setting up libtimedate-perl (1.2000-1) ... Setting up libdpkg-perl (1.16.18) ... Setting up dpkg-dev (1.16.18) ... Setting up build-essential (11.5) ... Setting up libalgorithm-diff-perl (1.19.02-2) ... Setting up libalgorithm-diff-xs-perl (0.04-2+b1) ... Setting up libalgorithm-merge-perl (0.08-2) ... Setting up libfile-fcntllock-perl (0.14-2) ...
pip version (using python-pip
package).
$ pip --version
pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
pip will not download any packages anymore or upgrade itself.
$ sudo pip install beautifulsoup4
pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7) milosz@debian:~$ sudo pip install beautifulsoup4 Downloading/unpacking beautifulsoup4 Cannot fetch index base URL http://pypi.python.org/simple/ Could not find any downloads that satisfy the requirement beautifulsoup4 No distributions at all found for beautifulsoup4 Storing complete log in /root/.pip/pip.log
The main problem is that it does not use HTTPS protocol.
$ sudo cat /root/.pip/pip.log
Downloading/unpacking beautifulsoup4 Getting page http://pypi.python.org/simple/beautifulsoup4 Could not fetch URL http://pypi.python.org/simple/beautifulsoup4: HTTP Error 403: SSL is required Will skip URL http://pypi.python.org/simple/beautifulsoup4 when looking for download links for beautifulsoup4 Getting page http://pypi.python.org/simple/ Could not fetch URL http://pypi.python.org/simple/: HTTP Error 403: SSL is required Will skip URL http://pypi.python.org/simple/ when looking for download links for beautifulsoup4 Cannot fetch index base URL http://pypi.python.org/simple/ URLs to search for versions for beautifulsoup4: * http://pypi.python.org/simple/beautifulsoup4/ Getting page http://pypi.python.org/simple/beautifulsoup4/ Could not fetch URL http://pypi.python.org/simple/beautifulsoup4/: HTTP Error 403: SSL is required Will skip URL http://pypi.python.org/simple/beautifulsoup4/ when looking for download links for beautifulsoup4 Could not find any downloads that satisfy the requirement beautifulsoup4
No distributions at all found for beautifulsoup4 Exception information: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 104, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 245, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/usr/lib/python2.7/dist-packages/pip/req.py", line 978, in prepare_files url = finder.find_requirement(req_to_install, upgrade=self.upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 157, in find_requirement raise DistributionNotFound('No distributions at all found for %s' % req) DistributionNotFound: No distributions at all found for beautifulsoup4
Provide package index URL using HTTPS protocol to upgrade pip to version 8.1.2.
$ sudo pip install --upgrade --index-url=https://pypi.python.org/simple/ pip==8.1.2
Downloading/unpacking pip from https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9 Downloading pip-9.0.1.tar.gz (1.2Mb): 1.2Mb downloaded Running setup.py egg_info for package pip /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching '.landscape.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'appveyor.yml' no previously-included directories found matching '.github' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Installing collected packages: pip Found existing installation: pip 1.1 Uninstalling pip: Successfully uninstalled pip Running setup.py install for pip /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching '.landscape.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'appveyor.yml' no previously-included directories found matching '.github' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin Successfully installed pip Cleaning up...
Upgraded pip version.
$ pip --version
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)
Install urllib3 with secure extra and ndg-httpsclient that provides enhanced HTTPS support using PyOpenSSL.
$ sudo pip install urllib3[secure] ndg-httpsclient
Collecting urllib3[secure] /usr/local/lib/python2.7/dist-packages/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. SNIMissingWarning /usr/local/lib/python2.7/dist-packages/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. InsecurePlatformWarning Downloading urllib3-1.22-py2.py3-none-any.whl (132kB) 100% |████████████████████████████████| 133kB 3.6MB/s Collecting ndg-httpsclient Downloading ndg_httpsclient-0.4.4-py2-none-any.whl Collecting idna>=2.0.0; python_version <= "2.7" and extra == "secure" (from urllib3[secure]) Downloading idna-2.6-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 6.8MB/s Collecting pyOpenSSL>=0.14; python_version <= "2.7" and extra == "secure" (from urllib3[secure]) Downloading pyOpenSSL-17.5.0-py2.py3-none-any.whl (53kB) 100% |████████████████████████████████| 61kB 6.7MB/s Collecting cryptography>=1.3.4; python_version <= "2.7" and extra == "secure" (from urllib3[secure]) Downloading cryptography-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB) 100% |████████████████████████████████| 2.2MB 495kB/s Collecting certifi; extra == "secure" (from urllib3[secure]) Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB) 100% |████████████████████████████████| 153kB 5.2MB/s Collecting ipaddress; python_version <= "2.7" and extra == "secure" (from urllib3[secure]) Downloading ipaddress-1.0.19.tar.gz Collecting pyasn1>=0.1.1 (from ndg-httpsclient) Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB) 100% |████████████████████████████████| 71kB 6.6MB/s Collecting six>=1.5.2 (from pyOpenSSL>=0.14; python_version <= "2.7" and extra == "secure"->urllib3[secure]) Downloading six-1.11.0-py2.py3-none-any.whl Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]) Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB) 100% |████████████████████████████████| 102kB 5.9MB/s Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]) Downloading cffi-1.11.4-cp27-cp27mu-manylinux1_x86_64.whl (406kB) 100% |████████████████████████████████| 409kB 2.4MB/s Collecting enum34; python_version < "3" (from cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]) Downloading enum34-1.1.6-py2-none-any.whl Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3.4; python_version <= "2.7" and extra == "secure"->urllib3[secure]) Downloading pycparser-2.18.tar.gz (245kB) 100% |████████████████████████████████| 256kB 3.9MB/s Installing collected packages: idna, asn1crypto, pycparser, cffi, enum34, six, ipaddress, cryptography, pyOpenSSL, certifi, urllib3, pyasn1, ndg-httpsclient Running setup.py install for pycparser ... done Running setup.py install for ipaddress ... done `zSuccessfully installed asn1crypto-0.24.0 certifi-2018.1.18 cffi-1.11.4 cryptography-2.1.4 enum34-1.1.6 idna-2.6 ipaddress-1.0.19 ndg-httpsclient-0.4.4 pyOpenSSL-17.5.0 pyasn1-0.4.2 pycparser-2.18 six-1.11.0 urllib3-1.22 /usr/local/lib/python2.7/dist-packages/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. InsecurePlatformWarning You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
Now it will work as expected.
$ sudo pip install beautifulsoup4
Collecting beautifulsoup4 Downloading beautifulsoup4-4.6.0-py2-none-any.whl (86kB) 100% |████████████████████████████████| 92kB 4.6MB/s Installing collected packages: beautifulsoup4 Successfully installed beautifulsoup4-4.6.0 You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
Problem solved.
Additional notes
Install pipdeptree to inspect Python package dependencies.
$ sudo pip install pipdeptree
Collecting pipdeptree Downloading pipdeptree-0.10.1-py2-none-any.whl Requirement already satisfied (use --upgrade to upgrade): pip>=6.0.0 in /usr/local/lib/python2.7/dist-packages (from pipdeptree) Installing collected packages: pipdeptree Successfully installed pipdeptree-0.10.1 You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
Inspect the following dependencies if you still see InsecurePlatformWarning and SNIMissingWarning warnings.
$ pipdeptree
beautifulsoup4==4.6.0 certifi==2018.1.18 distribute==0.6.24dev-r0 ndg-httpsclient==0.4.4 - pyasn1 [required: >=0.1.1, installed: 0.4.2] - PyOpenSSL [required: Any, installed: 17.5.0] - cryptography [required: >=2.1.4, installed: 2.1.4] - asn1crypto [required: >=0.21.0, installed: 0.24.0] - cffi [required: >=1.7, installed: 1.11.4] - pycparser [required: Any, installed: 2.18] - enum34 [required: Any, installed: 1.1.6] - idna [required: >=2.1, installed: 2.6] - ipaddress [required: Any, installed: 1.0.19] - six [required: >=1.4.1, installed: 1.11.0] - six [required: >=1.5.2, installed: 1.11.0] pipdeptree==0.10.1 - pip [required: >=6.0.0, installed: 8.1.2] setuptools==0.6rc11 urllib3==1.22
Disable pip version check if it annoys you.
$ sudo pip --disable-pip-version-check install beautifulsoup
Collecting beautifulsoup Downloading BeautifulSoup-3.2.1.tar.gz Installing collected packages: beautifulsoup Running setup.py install for beautifulsoup ... done Successfully installed beautifulsoup-3.2.1标签:upgrade,python,perl,How,version,pip,found,matching From: https://www.cnblogs.com/apexchu/p/18341624