【问题标题】:How to use py-requests in alpine linux docker?如何在 alpine linux docker 中使用 py-requests?
【发布时间】:2019-07-29 21:18:37
【问题描述】:

我构建了一个 python 应用程序,它在它的 docker 容器中愉快地运行,直到我添加了一些 http 调用。使用库“请求”。我做了一些研究,alpine linux 3.7 有一个名为“py-requests”的库。只是我似乎无法在我自己的系统上安装它,更改我的代码以使用它,并且只留下“导入请求”就会抛出错误' 在我的代码中。 Py-pip 似乎也不起作用。

【问题讨论】:

  • 在构建镜像时使用pip install requests;有requirements.txt for Python 你的包。
  • 你的问题确实不清楚。 Py-pip doesn't seem to work either,这意味着您已经使用 pip 安装了它? Only I can't seem to install this on my own system,这意味着你已经尝试安装它,命令是什么,如果出错,日志是什么? to change my code to use it, and errors are thrown just leaving 'import requests' in my code,怎么回事?见How to create a Minimal, Reproducible Example
  • 9000 和@atline 我无法使用 pip install 因为我被公司防火墙阻止了。我将 --proxy mycompanyproxy.com:80 --trusted-host pypi.org --trusted-host files.pythonhosted.org 添加到我的 dockerfile 的 pip install 命令中,并且能够得到我需要的东西。感谢您的评论,抱歉含糊不清,我是菜鸟:)

标签: python docker alpine


【解决方案1】:

我无法使用 pip install,因为我被公司防火墙阻止了。我将 --proxy mycompanyproxy.com:80 --trusted-host pypi.org --trusted-host files.pythonhosted.org 添加到我的 dockerfile 的 pip install 命令中,并且能够得到我需要的东西。感谢您的评论,并很抱歉含糊不清,我是菜鸟:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 2020-05-17
    • 1970-01-01
    相关资源
    最近更新 更多