21

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, and 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?

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DeltaIV
  • 4,773
  • 12
  • 39
  • 86
  • 1
    there is no difference between packages you install with `pip` directly or by common procedure (downoald and install from pypi or other sources) – Andersson Nov 30 '15 at 10:18
  • 2
    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 Nov 30 '15 at 10:28
  • @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](https://pypi.python.org/packages/cp27/n/numpy/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#md5=b582a9de1e411a20555c04b852d1f6d1) and got a `whl` file. No Windows installer. So how do I install it? – DeltaIV Nov 30 '15 at 10:56
  • I also tried `sourceforge`, precisely [this link](http://sourceforge.net/projects/numpy/files/latest/download?source=typ_redirect), 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 Nov 30 '15 at 10:56
  • you can use pip to install whl file that you got. http://stackoverflow.com/questions/28002897/wheel-file-installation `pip install wheel_file.whl` – otterb Nov 30 '15 at 10:58
  • thanks! apologies for the trivial question, but don't I need to tell `pip` about the directory where I downloaded the file? Like `pip install C:\Downloads\wheel_file.whl`. – DeltaIV Nov 30 '15 at 11:12
  • I navigated to the download directory 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.ma cosx_10_10_intel.macosx_10_10_x86_64.whl is not a supported wheel on this platform.`. What is happening? – DeltaIV Nov 30 '15 at 13:32
  • 1
    The clue is in the filename - that wheel is designed for OSX rather than Windows. Try one of the Windows binaries from [here](http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy), or install the [Anaconda Python distribution](https://www.continuum.io/downloads) instead. – ali_m Nov 30 '15 at 14:47
  • If someone has come to this page due to failing docker image builds which contain pip modules' installation from requirements file as a build step: Solution : Add `--dns 8.8.8.8` as parameters to `/etc/sysconfig/docker` and restart docker daemon and try `docker build` again – akskap Mar 10 '17 at 09:41

5 Answers5

20

A proxy shall be used. For example:

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

where "proxy.com:8080" is the 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. Mac OS X: How can I get Mac OS X's proxy information in a Bash script?
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

To bypass the firewall, you can use a proxy

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

For example,

pip install numpy --proxy http://<username>:<password>@proxy.xyz.com:2180
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tad
  • 811
  • 8
  • 16
  • While this code may answer the question, it lacks explanation. Please consider adding text to explain what it does, and why it answers the question posed. – Nelewout Aug 18 '18 at 09:04
1

If you use Anaconda:

I was trying to install Django using cmd, and it just was not working! I opened up the Anaconda prompt and ran the usual

py -m pip install Django

command, and hey presto! Django was installed!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
H4KKR
  • 64
  • 1
  • 8
0

Personally, it was the configuration file in ~/.config/pip/pip.conf, which contained an extra-index-url, preventing the download, because it made pip search for all the packages on this extra url instead of the main pip repository.

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

lolesque
  • 10,693
  • 5
  • 42
  • 42
  • What do you mean by *"blocking"*? In what way? Why and how does it block? Perhaps [elaborate](https://stackoverflow.com/posts/65684217/edit) a little bit in your answer? (But ***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today.) – Peter Mortensen Feb 05 '22 at 21:34
0

You could try this one as well! Setting pip configuration using a proxy so that you do not need to concern the proxy issue again when you install packages via pip.

pip config set global.proxy http://restrictedproxy.xxx.com:70

http://restrictedproxy.xxx.com 
:70

you could probably ask the proxy domain and the port from IT if you work for a company.

aVral
  • 65
  • 1
  • 9