如何让 Pycrypto 在 Docker 上正常工作?

Lui*_*ock 3 pycrypto python-3.x docker dockerfile

我正在AWS lambda 上使用Pychromeless 存储库并取得成功。

\n\n

但现在我需要使用 pycrypto 依赖项,但我得到了

\n\n

configure: error: no acceptable C compiler found in $PATH\n\xc2\xa0\n运行时make docker-build\n(放入文件后pycrypto==2.6.1requirements.txt

\n\n

这个线程,有人提到了同样的问题:\n\xc2\xa0

\n\n

“gcc 编译器不在您的 $PATH 中。这意味着您没有安装 gcc,或者它不在您的 $PATH 变量中”。

\n\n

所以尝试放置apt-get install build-essential在 Dockerfile 中,但我得到了

\n\n

/bin/sh: apt-get: command not found

\n\n

然后,我尝试使用\xc2\xa0yum install gcc

\n\n

只为得到

\n\n

The command \'/bin/sh -c yum install gcc\' returned a non-zero code: 1

\n\n

Docker-lambda [信息页面](https://hub.docker.com/r/lambci/lambda/)说:

\n\n
This project consists of a set of Docker images for each of the supported Lambda runtimes.\n\nThere are also a set of build images that include packages like gcc-c++, git, zip and the aws-cli for compiling and deploying.\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以我想我不需要安装 gcc。也许 gcc 编译器不在 $PATH 中,但我不知道该怎么解决这个问题。

\n\n

这是 dockerfile

\n\n
FROM lambci/lambda:python3.6\nMAINTAINER tech@21buttons.com\n\nUSER root\n\nENV APP_DIR /var/task\n\nWORKDIR $APP_DIR\n\nCOPY requirements.txt .\nCOPY bin ./bin\nCOPY lib ./lib\n\nRUN mkdir -p $APP_DIR/lib\nRUN pip3 install -r requirements.txt -t /var/task/lib\n
Run Code Online (Sandbox Code Playgroud)\n\n

有什么帮助解决这个问题吗?

\n

Lui*_*ock 5

好吧,好吧,好吧……今天对我来说是幸运的一天。

很简单:我所要做的就是更换

pycrypto==2.6.1

经过

pycryptodome

在我的requirements.txt 文件中。

帖子说:“强烈建议不要使用 pycrypto。它很旧,没有维护,并且包含许多漏洞。请改用 pycryptodome - 它是兼容的并且是最新的”。

就是这样!Docker 可以很好地构建pycryptodome.