繁体   English   中英

在 Windows 上使用 Pip 安装 NumPy

[英]Installing NumPy using Pip on Windows

我下载了 Python 3.6.1,它预装了 Pip。 我写了这个命令来安装 numpy

C:\Python36-32>python -m pip install numpy  

我得到这个作为输出:

收集 numpy 无法获取 URL https://pypi.python.org/simple/numpy/ :确认 ssl 证书时出现问题:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:749) - 跳过 找不到满足 numpy 要求的版本(来自版本:)没有找到 numpy 的匹配发行版

我该如何解决这个问题?
PS:我在 Windows 10 上执行此操作,以管理员身份运行命令提示符。

我使用以下命令解决了这个问题:

pip install numpy --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org

这个答案帮助我弄清楚了。

我已经使用以下命令解决了这个问题:

python.exe -m pip install numpy

例如:

C:\Users\Suresh\AppData\Local\Programs\Python\Python37>python.exe -m pip install numpy

在此处输入图片说明

确保首先通过选中 python exe 上的添加路径框将 python 路径添加到您的计算机。然后在命令提示符下运行pip install numpy

就我而言(Dockerfile 或 Linux),我们希望从需求 *.txt 文件中安装 pip 模块,这些文件在文件中定义了锁定模块的版本内部 Artifactory服务器(而不是在线即pypi.txt)获取。组织

例如:requirements.txt 文件

numpy==1.16.2
pandas==1.0.3
..
...

解决这个问题:我不得不使用NO_PROXY=<value>作为环境变量。

假设您的工件服务器是:my-artifactory。 company.local或 my-artifactory。 company.com ,那么我们需要确保的是NO_PROXY变量在其值中列出了该主机名的“”部分。

即对于我的人工制品。 company.com或 my-artifactory。 company.local ,里面的价值

NO_PROXY 变​​量必须包含: ,.company.com,.company.local,...

示例导出变量(在命令行 $ prompt ):

export NO_PROXY=localhost,127.0.0.1,169.254.169.254,169.254.169.123,.somecompany.com,.company.com,.company.local,pki.company.com,s3-us-gov-west-1.amazonaws.com,s3-fips-us-gov-west-1.amazonaws.com,rds.amazonaws.com,10.201.12.244,10.201.44.62,10.201.32.261

====

如果您使用的是Dockerfile ,那么请确保正确设置了 ARG/ENV 变量。 ARG 在构建时使用(可以在命令行使用发送到docker build -t tag . --build-arg 选项覆盖docker build -t tag .它将在当前目录中搜索 Dockerfile 并创建一个图像。ENV 在运行时使用( docker run ),也可以被覆盖。

示例 Dockerfile是:

FROM python:3.7

MAINTAINER giga.sangal@company.com

ARG PYTHONBUFFERED=0
ARG HTTPS_PROXY=http://proxy.ext.company.com:80
ARG HTTP_PROXY=http://proxy.ext.company.com:80
ARG NO_PROXY=localhost,127.0.0.1,169.254.169.254,.company.com,.company.local,pki.company.com,s3-us-gov-west-1.amazonaws.com,s3-fips-us-gov-west-1.amazonaws.com,rds.amazonaws.com

ENV PYTHONBUFFERED=${PYTHONBUFFERED}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV HTTP_PROXY=${HTTP_PROXY}
ENV NO_PROXY=${NO_PROXY}

# If there are 3 requirements files in source control, I'm copy all for pip install, you don't have to. Use what modules you want / file you want.    
RUN mkdir -p code
COPY requirements.txt /code
COPY requirements-test.txt /code
COPY requirements-dev.txt /code

WORKDIR /code

# You can fetch from pypi.org but in my case, this was a security issue.
# RUN pip install --trusted-host pypi.org -r requirements.txt

RUN pip install --no-cache-dir --trusted-host my-artifactory.company.local -r requirements.txt -r requirements-test.txt -r requirements-dev.txt --index-url http://my-artifactory.company.local:8081/artifactory/api/pypi/pypi-local-deps/simple --disable-pip-version-check

在我的案例中解决了这个问题的主线是使用 NO_PROXY(如上所列)。

与找不到 pip 模块或找不到模块版本相关的任何问题,或任何 SSL 错误SSLError(SSLCertVerificationError类似错误,在cmd 行Dockerfile应用上述 NO_PROXY 后消失

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)'))': /simple/requests/

或者

ERROR: Could not find a version that satisfies the requirement requests
ERROR: No matching distribution found for requests

或者

ERROR: Could not find a version that satisfies the requirement numpy==1.16.2
ERROR: No matching distribution found for numpy==1.16.2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM