5

Due to network constraints and certificates error I am not able to install python libraries using pip normally.

So I tried downloading .whl and install the library manually. However it also failed with the same error.

C:\python3.7>python -m pip install requests-2.21.0-py2.py3-none-any.whl
Processing c:\python3.7\requests-2.21.0-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests==2.21.0)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x039C3D90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567350>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567D10>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567FD0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04545F70>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Could not find a version that satisfies the requirement idna<2.9,>=2.5 (from requests==2.21.0) (from versions: )
No matching distribution found for idna<2.9,>=2.5 (from requests==2.21.0)

Tried --use-wheel option as suggested but doesn't work. Looks like pip is old, however I can't even upgrade pip because that also needs a proper working net. It's a catch22 situation.

C:\python3.7>python -m pip install --use-wheel requests-2.21.0-py2.py3-none-any.whl

Usage:
  C:\python3.7\python.exe -m pip install [options] <requirement specifier> [package-index-options] ...
  C:\python3.7\python.exe -m pip install [options] -r <requirements file> [package-index-options] ...
  C:\python3.7\python.exe -m pip install [options] [-e] <vcs project url> ...
  C:\python3.7\python.exe -m pip install [options] [-e] <local project path> ...
  C:\python3.7\python.exe -m pip install [options] <archive url/path> ...

no such option: --use-wheel

How can I manually install libraries?

garg10may
  • 5,794
  • 11
  • 50
  • 91

2 Answers2

3

The issue is not your wheel, that works. But this line is important:

No matching distribution found for idna<2.9,>=2.5 (from requests==2.21.0)

So you would need to download idna as well. Probably other dependencies as well.

$ python -m pip show requests
Requires: urllib3, chardet, idna, certifi

So you'll need those four as well. To be honest, I think you'll have a lot of difficulty trying to accomplish this all manually. The dependency tree might be several levels deep.

The Pjot
  • 1,801
  • 1
  • 12
  • 20
  • Oh :( that is cumbersome, is there a way I can have all the wheels downloaded required for that package. – garg10may Jan 29 '19 at 08:49
  • and `python -m pip shows requests` shows blank output – garg10may Jan 29 '19 at 08:50
  • Yes, I noticed that as well. The `show` only works if the module is installed. Have you tried this approach here? To avoid certificate problems: https://stackoverflow.com/a/29751768/1291498 – The Pjot Jan 29 '19 at 08:52
  • yes, see my other question. https://stackoverflow.com/questions/54406115/unable-to-install-using-pip-over-proxy I became so frustrated over that, my company IT is shit. I don't think I would be able to explain them the particular issue and I need to develop this POC ASAP – garg10may Jan 29 '19 at 08:53
  • Auch :( I feel your frustration. Afraid there's no other way then manually trying to find out what the dependencies are and download those. Starting from the lowest dependency. The good news is, from what I can see; for `requests` you only need those four I mentioned. They have no further dependencies! But I'm guessing requests is not the only requirement you have .. – The Pjot Jan 29 '19 at 08:58
  • hmm, probably will go with this for now. I would easily require like 100+ package including dependencies. – garg10may Jan 29 '19 at 09:02
  • when I like search for a particular lib say `urllib3` it shows so many options how to which is right, never faced issue with pip. `https://pypi.org/search/?q=urllib3` – garg10may Jan 29 '19 at 09:06
  • Just append the exact name as it says; https://pypi.org/project/urllib3/. But the pain here is that you might need a older version of some dependency. But seeing requests is quite new, this might not be an issue. But yeah, far from ideal. – The Pjot Jan 29 '19 at 09:10
3

On the machine with working pip, issue:

$ mkdir wheelhouse
$ pip download --dest wheelhouse requests

This will download requests and all its dependencies to the wheelhouse directory. Now move the directory to the target machine, there issue

$ pip install requests --no-index --find-links wheelhouse/

This will tell pip to not to search for packages online and instead look for them in the wheelhouse directory ("offline" install).

hoefling
  • 59,418
  • 12
  • 147
  • 194
  • ok, can I get like all or most of packages in a single go in wheelhouse? otherwise again and again I would have to download, move, install – garg10may Jan 29 '19 at 09:11
  • `pip download` will download the package and all its dependencies in one go, as long as you don't tell it to do the opposite with `--no-deps`. Also, check out my comment in your other question with a command suggestion. – hoefling Jan 29 '19 at 09:17
  • as in like all the collection of packages even if GB in size – garg10may Jan 29 '19 at 09:23
  • No, only every package required to install `requests`; four or five of them. – hoefling Jan 29 '19 at 09:28