18
votes

As per object. I'm running Python 2.7.10 under Windows 7 64 bit. I added C:\Python27\Scripts to my PATH, and I can run pip, but it's not able to install modules. For example

pip install numpy

gives

Collecting numpy
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after
connection broken by 'ProtocolError('Connection aborted.', gaierror(11004,'getaddrinfo failed'))': /simple/numpy/

It keeps retrying and failing for a while, then it exits with

Could not find a version that satisfies the requirement numpy (from versions:
)
No matching distribution found for numpy

Probably I'm behind a firewall, but I'm quite disappointed because I can install packages under R perfectly fine with install.packages, and I don't see why I can't do the same with Python. If I install packages manually (in the case of numpy, from here

numpy

what do I miss, with respect to using pip?

EDIT: as per suggestions in the comments, I downloaded the .whl file for numpy from numpy, I navigated to the downloads dir and executed

  pip install numpy-1.10.1-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

I only got

  numpy-1.10.1-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl is not a supported wheel on this platform.

What should I do?

4
there is no difference between packages you install with pip directly or by common procedure (downoald and install from pypi or other sources) - Andersson
Anyway, module/packages with C-extension such as numpy needs C compilation during pip install which is not trivial especially on Windows. I would highly recommend downloading binary distribution from official site or C. Gohlke's site. On Windows, pip works only when modules are pure python or pypi has wheel package unless you have proper build system. - otterb
@otterb I'm 100% in favor of using binaries whenever possible, but how do I do that? from the page I link in my question, I clicked this link and got a whl file. No Windows installer. So how do I install it? - DeltaIV
I also tried sourceforge, precisely this link, and this time I got a zip file containing various folders with py files, but again I don't know what to do with them. - DeltaIV
The clue is in the filename - that wheel is designed for OSX rather than Windows. Try one of the Windows binaries from here, or install the Anaconda Python distribution instead. - ali_m

4 Answers

16
votes

Proxy shall be used. For example:

python.exe -m pip install numpy --proxy="proxy.com:8080"

where "proxy.com:8080" is proxy server address and port. This can be found in OS settings.

How to get them:

  1. Windows: What Is a Proxy or Proxy Server
  2. Linux How can I find out the proxy address I am behind?
  3. OSX: How can I get Mac OS X's proxy information in a Bash script?
2
votes

To bypass the firewall you can use proxy

pip install numpy --proxy <domain\user:password@proxyaddress:port>

eg.,

pip install numpy --proxy http://<username>:<password>@proxy.xyz.com:2180
0
votes

Do you by any chance use Anaconda?

I was hitting my head against the wall for hours trying to install Django using cmd, and it just was not working! I opened up the Anaconda Prompt, ran the usual

py -m pip install Django

command, and hey presto! Django installed!!

0
votes

Personally, it was the conf file in ~/.config/pip/pip.conf (which contained extra-index-url) blocking.

Experimented with old pip 8 because upgrading was even worse for this extra-index-url needed for another project.