适用于bokeh的AWS Lambda层

时间:2019-02-05 19:54:14

标签: amazon-web-services docker aws-lambda bokeh

我按照以下文章中提到的步骤创建了lambda层所需的文件

https://medium.com/@qtangs/creating-new-aws-lambda-layer-for-python-pandas-library-348b126e9f3e

requires.txt的外观如下

bokeh==1.0.4
Jinja2==2.1
MarkupSafe==1.0
pillow==5.1.0
packaging==17.1
tornado==5.0.2
pyYAML==3.12
six==1.11.0

get_layer_packages.sh

#!/bin/bash

export PKG_DIR="python"

rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR}

docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.6 \
    pip install -r requirements.txt --no-deps -t ${PKG_DIR}

当我尝试执行./get_layer_packages.sh时,出现以下错误:

任何想法为什么会失败。我按照上述步骤操作了其他库,效果很好

/var/lang/lib/python3.6/distutils/core.py:108: DistDeprecationWarning: Features are deprecated and will be removed in a future version. See https://github.com/pypa/setuptools/issues/65.
    _setup_distribution = dist = klass(attrs)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/ext.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/tests.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/compiler.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/parser.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/__init__.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/_ipysupport.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/runtime.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/constants.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/visitor.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/environment.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/lexer.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/exceptions.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/filters.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/optimizer.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/nodes.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/utils.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/debug.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/sandbox.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/defaults.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/bccache.py -> build/lib.linux-x86_64-3.6/jinja2
  copying jinja2/loaders.py -> build/lib.linux-x86_64-3.6/jinja2
  running build_ext
  building 'jinja2._speedups' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/jinja2
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/var/lang/include/python3.6m -c jinja2/_speedups.c -o build/temp.linux-x86_64-3.6/jinja2/_speedups.o
  jinja2/_speedups.c: In function ‘init_constants’:
  jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
   #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                   ^
  jinja2/_speedups.c:36:28: note: in expansion of macro ‘UNICHR’
    escaped_chars_repl['"'] = UNICHR(""");
                              ^
  jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
   #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                   ^
  jinja2/_speedups.c:37:29: note: in expansion of macro ‘UNICHR’
    escaped_chars_repl['\''] = UNICHR("'");
                               ^
  jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
   #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                   ^
  jinja2/_speedups.c:38:28: note: in expansion of macro ‘UNICHR’
    escaped_chars_repl['&'] = UNICHR("&");
                              ^
  jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
   #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                   ^
  jinja2/_speedups.c:39:28: note: in expansion of macro ‘UNICHR’
    escaped_chars_repl['<'] = UNICHR("&lt;");
                              ^
  jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
   #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                   ^
  jinja2/_speedups.c:40:28: note: in expansion of macro ‘UNICHR’
    escaped_chars_repl['>'] = UNICHR("&gt;");
                              ^
  jinja2/_speedups.c: In function ‘escape_unicode’:
  jinja2/_speedups.c:62:22: error: ‘PyUnicodeObject’ has no member named ‘str’
    Py_UNICODE *inp = in->str;
                        ^
  jinja2/_speedups.c:63:32: error: ‘PyUnicodeObject’ has no member named ‘str’
    const Py_UNICODE *inp_end = in->str + in->length;
                                  ^
  jinja2/_speedups.c:63:42: error: ‘PyUnicodeObject’ has no member named ‘length’
    const Py_UNICODE *inp_end = in->str + in->length;
                                            ^
  jinja2/_speedups.c:83:56: error: ‘PyUnicodeObject’ has no member named ‘length’
    out = (PyUnicodeObject*)PyUnicode_FromUnicode(NULL, in->length + delta);
                                                          ^
  jinja2/_speedups.c:87:12: error: ‘PyUnicodeObject’ has no member named ‘str’
    outp = out->str;
              ^
  jinja2/_speedups.c:88:10: error: ‘PyUnicodeObject’ has no member named ‘str’
    inp = in->str;
            ^
  In file included from /var/lang/include/python3.6m/Python.h:77:0,
                   from jinja2/_speedups.c:15:
  jinja2/_speedups.c:114:32: error: ‘PyUnicodeObject’ has no member named ‘length’
     Py_UNICODE_COPY(outp, inp, in->length - (inp - in->str));
                                  ^
  /var/lang/include/python3.6m/unicodeobject.h:159:33: note: in definition of macro ‘Py_UNICODE_COPY’
       memcpy((target), (source), (length)*sizeof(Py_UNICODE))
                                   ^
  jinja2/_speedups.c:114:52: error: ‘PyUnicodeObject’ has no member named ‘str’
     Py_UNICODE_COPY(outp, inp, in->length - (inp - in->str));
                                                      ^
  /var/lang/include/python3.6m/unicodeobject.h:159:33: note: in definition of macro ‘Py_UNICODE_COPY’
       memcpy((target), (source), (length)*sizeof(Py_UNICODE))
                                   ^
  jinja2/_speedups.c: In function ‘escape’:
  jinja2/_speedups.c:126:2: warning: implicit declaration of function ‘PyInt_CheckExact’ [-Wimplicit-function-declaration]
    if (PyInt_CheckExact(text) || PyLong_CheckExact(text) ||
    ^
  jinja2/_speedups.c:142:3: warning: implicit declaration of function ‘PyObject_Unicode’ [-Wimplicit-function-declaration]
     PyObject *unicode = PyObject_Unicode(text);
     ^
  jinja2/_speedups.c:142:23: warning: initialization makes pointer from integer without a cast [enabled by default]
     PyObject *unicode = PyObject_Unicode(text);
                         ^
  jinja2/_speedups.c: In function ‘soft_unicode’:
  jinja2/_speedups.c:162:3: warning: return makes pointer from integer without a cast [enabled by default]
     return PyObject_Unicode(s);
     ^
  jinja2/_speedups.c: In function ‘init_speedups’:
  jinja2/_speedups.c:218:3: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
     return;
     ^
  jinja2/_speedups.c:220:2: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
    Py_InitModule3("jinja2._speedups", module_methods, "");
    ^
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Running setup.py clean for Jinja2
  Running setup.py bdist_wheel for MarkupSafe: started
  Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/33/56/20/ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46
  Running setup.py bdist_wheel for tornado: started
  Running setup.py bdist_wheel for tornado: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/29/8c/cf/6a5a8f6e35d877c0cb72b109d21c34981504897ce9a605e599
  Running setup.py bdist_wheel for pyYAML: started
  Running setup.py bdist_wheel for pyYAML: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/03/05/65/bdc14f2c6e09e82ae3e0f13d021e1b6b2481437ea2f207df3f
Successfully built bokeh MarkupSafe tornado pyYAML
Failed to build Jinja2
Installing collected packages: bokeh, Jinja2, MarkupSafe, pillow, packaging, tornado, pyYAML, six, python-dateutil, numpy
  Running setup.py install for Jinja2: started
    Running setup.py install for Jinja2: finished with status 'error'
    Complete output from command /var/lang//bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-pc4o6g1g/Jinja2/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-qoongv0a/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-r52hwsvl:
    /tmp/pip-install-pc4o6g1g/Jinja2/setup.py:109: DistDeprecationWarning: Features are deprecated and will be removed in a future version. See https://github.com/pypa/setuptools/issues/65.
      Extension('jinja2._speedups', ['jinja2/_speedups.c'])
    /var/lang/lib/python3.6/distutils/core.py:108: DistDeprecationWarning: Features are deprecated and will be removed in a future version. See https://github.com/pypa/setuptools/issues/65.
      _setup_distribution = dist = klass(attrs)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/ext.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/tests.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/compiler.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/parser.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/__init__.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/_ipysupport.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/runtime.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/constants.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/visitor.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/environment.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/lexer.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/exceptions.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/filters.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/optimizer.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/nodes.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/utils.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/debug.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/sandbox.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/defaults.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/bccache.py -> build/lib.linux-x86_64-3.6/jinja2
    copying jinja2/loaders.py -> build/lib.linux-x86_64-3.6/jinja2
    running build_ext
    building 'jinja2._speedups' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/jinja2
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/var/lang/include/python3.6m -c jinja2/_speedups.c -o build/temp.linux-x86_64-3.6/jinja2/_speedups.o
    jinja2/_speedups.c: In function ‘init_constants’:
    jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
     #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                     ^
    jinja2/_speedups.c:36:28: note: in expansion of macro ‘UNICHR’
      escaped_chars_repl['"'] = UNICHR("&#34;");
                                ^
    jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
     #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                     ^
    jinja2/_speedups.c:37:29: note: in expansion of macro ‘UNICHR’
      escaped_chars_repl['\''] = UNICHR("&#39;");
                                 ^
    jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
     #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                     ^
    jinja2/_speedups.c:38:28: note: in expansion of macro ‘UNICHR’
      escaped_chars_repl['&'] = UNICHR("&amp;");
                                ^
    jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
     #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                     ^
    jinja2/_speedups.c:39:28: note: in expansion of macro ‘UNICHR’
      escaped_chars_repl['<'] = UNICHR("&lt;");
                                ^
    jinja2/_speedups.c:18:81: error: ‘PyUnicodeObject’ has no member named ‘str’
     #define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str);
                                                                                     ^
    jinja2/_speedups.c:40:28: note: in expansion of macro ‘UNICHR’
      escaped_chars_repl['>'] = UNICHR("&gt;");
                                ^
    jinja2/_speedups.c: In function ‘escape_unicode’:
    jinja2/_speedups.c:62:22: error: ‘PyUnicodeObject’ has no member named ‘str’
      Py_UNICODE *inp = in->str;
                          ^
    jinja2/_speedups.c:63:32: error: ‘PyUnicodeObject’ has no member named ‘str’
      const Py_UNICODE *inp_end = in->str + in->length;
                                    ^
    jinja2/_speedups.c:63:42: error: ‘PyUnicodeObject’ has no member named ‘length’
      const Py_UNICODE *inp_end = in->str + in->length;
                                              ^
    jinja2/_speedups.c:83:56: error: ‘PyUnicodeObject’ has no member named ‘length’
      out = (PyUnicodeObject*)PyUnicode_FromUnicode(NULL, in->length + delta);
                                                            ^
    jinja2/_speedups.c:87:12: error: ‘PyUnicodeObject’ has no member named ‘str’
      outp = out->str;
                ^
    jinja2/_speedups.c:88:10: error: ‘PyUnicodeObject’ has no member named ‘str’
      inp = in->str;
              ^
    In file included from /var/lang/include/python3.6m/Python.h:77:0,
                     from jinja2/_speedups.c:15:
    jinja2/_speedups.c:114:32: error: ‘PyUnicodeObject’ has no member named ‘length’
       Py_UNICODE_COPY(outp, inp, in->length - (inp - in->str));
                                    ^
    /var/lang/include/python3.6m/unicodeobject.h:159:33: note: in definition of macro ‘Py_UNICODE_COPY’
         memcpy((target), (source), (length)*sizeof(Py_UNICODE))
                                     ^
    jinja2/_speedups.c:114:52: error: ‘PyUnicodeObject’ has no member named ‘str’
       Py_UNICODE_COPY(outp, inp, in->length - (inp - in->str));
                                                        ^
    /var/lang/include/python3.6m/unicodeobject.h:159:33: note: in definition of macro ‘Py_UNICODE_COPY’
         memcpy((target), (source), (length)*sizeof(Py_UNICODE))
                                     ^
    jinja2/_speedups.c: In function ‘escape’:
    jinja2/_speedups.c:126:2: warning: implicit declaration of function ‘PyInt_CheckExact’ [-Wimplicit-function-declaration]
      if (PyInt_CheckExact(text) || PyLong_CheckExact(text) ||
      ^
    jinja2/_speedups.c:142:3: warning: implicit declaration of function ‘PyObject_Unicode’ [-Wimplicit-function-declaration]
       PyObject *unicode = PyObject_Unicode(text);
       ^
    jinja2/_speedups.c:142:23: warning: initialization makes pointer from integer without a cast [enabled by default]
       PyObject *unicode = PyObject_Unicode(text);
                           ^
    jinja2/_speedups.c: In function ‘soft_unicode’:
    jinja2/_speedups.c:162:3: warning: return makes pointer from integer without a cast [enabled by default]
       return PyObject_Unicode(s);
       ^
    jinja2/_speedups.c: In function ‘init_speedups’:
    jinja2/_speedups.c:218:3: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
       return;
       ^
    jinja2/_speedups.c:220:2: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
      Py_InitModule3("jinja2._speedups", module_methods, "");
      ^
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/var/lang//bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-pc4o6g1g/Jinja2/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-qoongv0a/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-r

52hwsvl”失败,错误代码为/ tmp / pip-install-pc4o6g1g / Jinja2 /

1 个答案:

答案 0 :(得分:0)

发现了问题,Jinja的版本号是2.10而不是2.1

requirements.txt

bokeh==1.0.4
Jinja2==2.10
MarkupSafe==1.0
pillow==5.1.0
packaging==17.1
tornado==5.0.2
pyYAML==3.12
six==1.11.0