且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

pip无法在Mac上的Docker容器内安装软件包

更新时间:2022-06-13 06:03:32

我发现这是一个pip代理错误,并且能够通过将代理指定为pip安装的参数来解决此问题.因此,不仅仅是拥有

I have found out that this is a pip proxy error and was able to solve the issue by specifying the proxy as a parameter to pip install. So instead of simply having

#Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt

在我的Dockerfile中,我有

#Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt --proxy http(s)://proxy:8080 --trusted-host pypi.python.org

--proxy http(s)://proxy:8080指定pip使用的代理,并且--trusted-host pypi.python.org启用pypi作为受信任的主机,以防万一遇到ssl证书错误(在公司环境中很常见).

The --proxy http(s)://proxy:8080 specifies the proxy to be used by pip and --trusted-host pypi.python.org enables pypi as a trusted host just in case ssl certificate errors are encountered (common in corporate environments).