从commonmark.main导入commonmark抛出“ ModuleNotFoundError:没有名为'commonmark'的模块”

时间:2019-02-10 07:35:40

标签: python commonmark

早上好。我正在尝试安装一个简单的Python应用程序来满足需求。我从this GitHub repo下载了它。当我尝试使用“ make run”命令启动应用程序时,它给了我以下错误:

E:\contentful\python\the-example-app.py>make run
python app.py
Traceback (most recent call last):
  File "app.py", line 10, in <module>
    from lib.markdown import markdown
  File "E:\contentful\python\the-example-app.py\lib\markdown.py", line 1, in <module>
    import CommonMark
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\CommonMark\__init__.py", line 4, in <module>
    from commonmark.main import commonmark
ModuleNotFoundError: No module named 'commonmark'
make: *** [run] Error 1

我不确定如何解决此错误。我在CommonMark文件夹中找到了main.py。 main.py代码如下所示。

# 2014 - Bibek Kafle & Roland Shoemaker
# 2015-2017 - Nikolas Nyby
# Port of @jgm's commonmark.js implementation of the CommonMark spec.

# Basic usage:
#
# import commonmark
# parser = commonmark.Parser()
# renderer = commonmark.HtmlRenderer()
# print(renderer.render(parser.parse('Hello *world*')))

from __future__ import absolute_import, unicode_literals

from commonmark.blocks import Parser
from commonmark.dump import dumpAST, dumpJSON
from commonmark.render.html import HtmlRenderer
from commonmark.render.rst import ReStructuredTextRenderer


def commonmark(text, format="html"):
    """Render CommonMark into HTML, JSON or AST
    Optional keyword arguments:
    format:     'html' (default), 'json' or 'ast'

    >>> commonmark("*hello!*")
    '<p><em>hello</em></p>\\n'
    """
    parser = Parser()
    ast = parser.parse(text)
    if format not in ["html", "json", "ast", "rst"]:
        raise ValueError("format must be 'html', 'json' or 'ast'")
    if format == "html":
        renderer = HtmlRenderer()
        return renderer.render(ast)
    if format == "json":
        return dumpJSON(ast)
    if format == "ast":
        return dumpAST(ast)
    if format == "rst":
        renderer = ReStructuredTextRenderer()
        return renderer.render(ast)

我不知道如何进行,请您帮我运行python应用程序。非常感谢您的帮助。

谢谢 Venu

0 个答案:

没有答案