Python pip 没有安装模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33996026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 14:17:51  来源:igfitidea点击:

pip not installing modules

pythonnumpypip

提问by DeltaIV

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

按对象。我在 Windows 7 64 位下运行 Python 2.7.10。我将 C:\Python27\Scripts 添加到我的 PATH,并且我可以运行pip,但它无法安装模块。例如

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 Rperfectly 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

可能我在防火墙后面,但我很失望,因为我可以R用 完美地安装软件包install.packages,而且我不明白为什么我不能用 Python 做同样的事情。如果我手动安装软件包(在 的情况下numpy,从这里

numpy

麻木的

what do I miss, with respect to using pip?

关于使用,我想念什么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

编辑:根据评论中的建议,我从numpy下载了 numpy 的 .whl 文件,我导航到下载目录并执行

  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?

我该怎么办?

采纳答案by Seweryn Habdank-Wojewódzki

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.

其中“proxy.com:8080”是代理服务器地址和端口。这可以在操作系统设置中找到。

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?
  1. Windows:什么是代理或代理服务器
  2. Linux如何查到我背后的代理地址?
  3. OSX:如何在 Bash 脚本中获取 Mac OS X 的代理信息?

回答by Tad

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

回答by H4KKR

Do you by any chance use Anaconda?

你有机会使用 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

我在尝试使用 cmd 安装 Django 时,头撞墙了几个小时,但它不起作用!我打开了 Anaconda Prompt,运行了通常的

py -m pip install Django

command, and hey presto! Django installed!!

命令,嘿,快!安装了Django!!