在docker容器中安装m2crypto

时间:2019-06-07 01:13:12

标签: python pip m2crypto

尝试在Dockerfile中安装m2crypto:

FROM python:3.7
RUN pip install m2crypto

我收到以下错误输出(被截断):

Step 7/8 : RUN pip install m2crypto
 ---> Running in 1204096f1488
Collecting m2crypto
  Downloading https://files.pythonhosted.org/packages/23/93/1c1a887f956ec38d691af110d38059e234fc941019e0c074a66a10846813/M2Crypto-0.34.0.tar.gz (1.1MB)
Building wheels for collected packages: m2crypto
  Building wheel for m2crypto (setup.py): started
  Building wheel for m2crypto (setup.py): finished with status 'error'
  ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w9seu9sh --python-tag cp37:
  ERROR: running bdist_wheel
...
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -I/tmp/pip-install-ptf_nqd5/m2crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-x86_64-3.7/SWIG/_m2crypto_wrap.o -Wno-deprecated-declarations -DTHREADING
  SWIG/_m2crypto_wrap.c: In function ‘_wrap__STACK_num_set’:
  SWIG/_m2crypto_wrap.c:9506:19: error: dereferencing pointer to incomplete type ‘struct stack_st’
     if (arg1) (arg1)->num = arg2;
                     ^~
... lots more errors ...
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xq22_pd8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ptf_nqd5/m2crypto/

https://pastebin.com/3bmdGvdx的完整输出。

我做错什么了吗?

1 个答案:

答案 0 :(得分:1)

按照installation instructions自己解决它:

FROM python:3.7
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y python3-dev
RUN apt-get install -y swig
RUN pip install m2crypto
说明中提到了

libssl-dev,但已经存在。需要apt-get update,否则将找不到build-essential。因为-y很大,所以需要python3-dev,否则apt-get install会提示“您要安装吗?[是/否]”。

我敢肯定,使用其他基本图像,此方法的许多其他变体也将起作用。但这确实有效。