2017-04-17 39 views
0

我正在构建一个包以作为AWS Lambda函数上载。试图在Markdown 2.6.8中引入一个依赖项,一个Markdown的python实现。试图测试该功能时,出现错误Unable to import module 'markdown-convert': No module named markdown。我从其他类似的问题中看到,我可能需要编译Amazon Linux内部的依赖文件以使它们可用于Lambda。我不熟悉python,也不知道我是否也应该探索这个代码在一个蛋中打包的方式,以及它是否会影响依赖关系的导入方式。你会怎么建议我试图解决这个错误?在Python中包含markdown转换器依赖关系AWS Lambda函数

这里是我包的文件结构:

. 
    ├── markdown 
    │   ├── blockparser.py 
    │   ├── blockprocessors.py 
    │   ├── extensions 
    │   │   ├── abbr.py 
    │   │   ├── admonition.py 
    │   │   ├── attr_list.py 
    │   │   ├── codehilite.py 
    │   │   ├── def_list.py 
    │   │   ├── extra.py 
    │   │   ├── fenced_code.py 
    │   │   ├── footnotes.py 
    │   │   ├── headerid.py 
    │   │   ├── __init__.py 
    │   │   ├── meta.py 
    │   │   ├── nl2br.py 
    │   │   ├── __pycache__ 
    │   │   │   ├── abbr.cpython-34.pyc 
    │   │   │   ├── admonition.cpython-34.pyc 
    │   │   │   ├── attr_list.cpython-34.pyc 
    │   │   │   ├── codehilite.cpython-34.pyc 
    │   │   │   ├── def_list.cpython-34.pyc 
    │   │   │   ├── extra.cpython-34.pyc 
    │   │   │   ├── fenced_code.cpython-34.pyc 
    │   │   │   ├── footnotes.cpython-34.pyc 
    │   │   │   ├── headerid.cpython-34.pyc 
    │   │   │   ├── __init__.cpython-34.pyc 
    │   │   │   ├── meta.cpython-34.pyc 
    │   │   │   ├── nl2br.cpython-34.pyc 
    │   │   │   ├── sane_lists.cpython-34.pyc 
    │   │   │   ├── smart_strong.cpython-34.pyc 
    │   │   │   ├── smarty.cpython-34.pyc 
    │   │   │   ├── tables.cpython-34.pyc 
    │   │   │   ├── toc.cpython-34.pyc 
    │   │   │   └── wikilinks.cpython-34.pyc 
    │   │   ├── sane_lists.py 
    │   │   ├── smart_strong.py 
    │   │   ├── smarty.py 
    │   │   ├── tables.py 
    │   │   ├── toc.py 
    │   │   └── wikilinks.py 
    │   ├── __init__.py 
    │   ├── inlinepatterns.py 
    │   ├── __main__.py 
    │   ├── odict.py 
    │   ├── postprocessors.py 
    │   ├── preprocessors.py 
    │   ├── __pycache__ 
    │   │   ├── blockparser.cpython-34.pyc 
    │   │   ├── blockprocessors.cpython-34.pyc 
    │   │   ├── __init__.cpython-34.pyc 
    │   │   ├── inlinepatterns.cpython-34.pyc 
    │   │   ├── __main__.cpython-34.pyc 
    │   │   ├── odict.cpython-34.pyc 
    │   │   ├── postprocessors.cpython-34.pyc 
    │   │   ├── preprocessors.cpython-34.pyc 
    │   │   ├── serializers.cpython-34.pyc 
    │   │   ├── treeprocessors.cpython-34.pyc 
    │   │   ├── util.cpython-34.pyc 
    │   │   └── __version__.cpython-34.pyc 
    │   ├── serializers.py 
    │   ├── treeprocessors.py 
    │   ├── util.py 
    │   └── __version__.py 
    ├── Markdown-2.6.8.egg-info 
    │   ├── dependency_links.txt 
    │   ├── installed-files.txt 
    │   ├── PKG-INFO 
    │   ├── SOURCES.txt 
    │   └── top_level.txt 
    └── markdown-convert.py 

markdown-convert.py的内容:

import markdown 

def lambda_handler(event, context): 
    parsedHTML = {} 
    parsedHTML[u'text'] = markdown.markdown(event[u'text']) 
    return parsedHTML 

回答