在将python spacy应用程序部署到aws lambda时,我在部署中得到以下错误(请参见下文)。为什么使用Zappa部署?zip文件是125mb压缩的,因此aws cli的直接上载在空间上失败,而传输到s3的操作也失败,因为未压缩的文件超过250mb。
我的程序本身不做任何多线程或多处理,它只使用Spacy2.0。我在ec2awslinuxt2.medium上构建和部署。从spacy aws lambda函数获得往返答案的确切步骤是什么?
故障跟踪如下:

[1520570028387] Failed to find library...right filename?
[1520570029826] [Errno 38] Function not implemented: OSError
Traceback (most recent call last):
  File "/var/task/handler.py", line 509, in lambda_handler
  return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 237, in lambda_handler
  handler = cls()
  File "/var/task/handler.py", line 129, in __init__
  self.app_module = importlib.import_module(self.settings.APP_MODULE)
  File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/tmp/spaciness/front.py", line 1, in <module>
  import spacy
  File "/tmp/spaciness/spacy/__init__.py", line 4, in <module>
  from .cli.info import info as cli_info
  File "/tmp/spaciness/spacy/cli/__init__.py", line 1, in <module>
  from .download import download
  File "/tmp/spaciness/spacy/cli/download.py", line 10, in <module>
  from .link import link
  File "/tmp/spaciness/spacy/cli/link.py", line 7, in <module>
  from ..compat import symlink_to, path2str
  File "/tmp/spaciness/spacy/compat.py", line 11, in <module>
  from thinc.neural.util import copy_array
  File "/tmp/spaciness/thinc/neural/__init__.py", line 1, in <module>
  from ._classes.model import Model
  File "/tmp/spaciness/thinc/neural/_classes/model.py", line 12, in <module>
  from ..train import Trainer
  File "/tmp/spaciness/thinc/neural/train.py", line 7, in <module>
  from tqdm import tqdm
  File "/tmp/spaciness/tqdm/__init__.py", line 1, in <module>
  from ._tqdm import tqdm
  File "/tmp/spaciness/tqdm/_tqdm.py", line 53, in <module>
  mp_lock = mp.Lock()  # multiprocessing lock
  File "/var/lang/lib/python3.6/multiprocessing/context.py", line 67, in Lock
  return Lock(ctx=self.get_context())
  File "/var/lang/lib/python3.6/multiprocessing/synchronize.py", line 163, in __init__
  SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File "/var/lang/lib/python3.6/multiprocessing/synchronize.py", line 60, in __init__
  unlink_now)
OSError: [Errno 38] Function not implemented

最佳答案

我可以通过以下步骤解决问题:
zappa_settings.json中增加lambda函数的内存大小:
{
“开发”:{

    "memory_size": 3008,
}

}
我不得不使用新版本的tqdm。默认情况下,版本为4.19,出现了如下所述的问题:https://github.com/tqdm/tqdm/issues/466
所述问题已在较新版本中修复只需将tqdm添加到myrequirements.txt并对包执行pip升级:
pip install -U tqdm

当我执行zappa deploy dev时,现在得到以下消息:
(tqdm 4.32.1(/var/task/ve/lib/python3.6/site包),Requirement.parse('tqdm==4.19.1'),{'zappa'})
TQM4.19.1是zappa的默认版本,TQM4.32.1是包含修复程序的新版本。

10-06 12:12