You want to use pip to install a module from PyPI. However your server distribution in a little old (at the time of writing this did not need to be all that old, so the problem has come up for me a number of times):
example@localhost:~/piptest$ pip install mkdocs Downloading/unpacking mkdocs Cannot fetch index base URL http://pypi.python.org/simple/ Could not find any downloads that satisfy the requirement mkdocs No distributions at all found for mkdocs Storing complete log in /home/example/.pip/pip.log
A first but not great fix is to simply override the install prefix using:
$ pip install --index-url=https://pypi.python.org/simple/ mkdocs
However this implies using an often very out-of-date and insecure version of pip, so aside not strictly helpful answers like upgrading the server or distribution the following short process can at least get you going when trying to get stuff done.
This uses virtualenv which is not strictly necessary but it does make life a bit easier and let’s you solve the problem without making any system-level changes (other than perhaps installing virtualenv). The super summary is to do the following:
-
mkdir project; cd project; virtualenv .; . bin/activate
-
pip install --index-url=https://pypi.python.org/simple/ --upgrade pip
Start by initialising virtualenv and activating it
example@localhost:~/pip-demo$ virtualenv . New python executable in ./bin/python Installing distribute.............................................................................................................................................................................................done. Installing pip...............done. example@localhost:~/pip-demo$. bin/activate
At this stage if we try and use the old pip it will fail due to the old URL.
Update pip and override the index-url
(pip-demo)example@localhost:~/pip-demo$ pip install --index-url=https://pypi.python.org/simple/ --upgrade pip Downloading/unpacking pip from https://files.pythonhosted.org/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz#sha256=a0e11645ee37c90b40c46d607070c4fd583e2cd46231b1c06e389c5e814eed76 Downloading pip-18.0.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) ... <skip some output> ... Installing pip script to /home/example/pip-demo/bin Installing pip2.7 script to /home/example/pip-demo/bin Installing pip2 script to /home/example/pip-demo/bin Successfully installed pip Cleaning up...
Note above the “distribute” warning – this also breaks other modules so…
(pip-demo)example@localhost:~/pip-demo$ pip install --upgrade distribute /home/example/pip-demo/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:369: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server 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.io/en/latest/advanced-usage.html#ssl-warnings SNIMissingWarning /home/example/pip-demo/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:160: 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.io/en/latest/advanced-usage.html#ssl-warnings InsecurePlatformWarning Collecting distribute Using cached https://files.pythonhosted.org/packages/5f/ad/1fde06877a8d7d5c9b60eff7de2d452f639916ae1d48f0b8f97bf97e570a/distribute-0.7.3.zip Collecting setuptools>=0.7 (from distribute) Using cached https://files.pythonhosted.org/packages/66/e8/570bb5ca88a8bcd2a1db9c6246bb66615750663ffaaeada95b04ffe74e12/setuptools-40.2.0-py2.py3-none-any.whl Installing collected packages: setuptools, distribute Found existing installation: distribute 0.6.24 Uninstalling distribute-0.6.24: Successfully uninstalled distribute-0.6.24 Running setup.py install for distribute ... done Successfully installed distribute-0.7.3 setuptools-40.2.0
And now we can install direct and more safely using the current pip (with some SSL warnings)
(pip-demo)example@localhost:~/pip-demo$ pip install mkdocs Collecting mkdocs /home/example/pip-demo/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:369: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server 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.io/en/latest/advanced-usage.html#ssl-warnings SNIMissingWarning /home/example/pip-demo/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:160: 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.io/en/latest/advanced-usage.html#ssl-warnings InsecurePlatformWarning ... <skip some output> ... Installing collected packages: click, Markdown, MarkupSafe, Jinja2, backports.ssl-match-hostname, backports-abc, certifi, six, singledispatch, tornado, livereload, PyYAML, mkdocs Successfully installed Jinja2-2.10 Markdown-2.6.11 MarkupSafe-1.0 PyYAML-3.13 backports-abc-0.5 backports.ssl-match-hostname-3.5.0.1 certifi-2018.8.24 click-6.7 livereload-2.5.2 mkdocs-0.17.5 singledispatch-3.4.0.3 six-1.11.0 tornado-4.5.3