【问题标题】:Trying to knit Rmarkdown but getting pandoc.utils error or pandoc error 83尝试编织 Rmarkdown 但出现 pandoc.utils 错误或 pandoc 错误 83
【发布时间】:2020-06-05 11:14:15
【问题描述】:

我是 Rmarkdown 新手,正在尝试学习如何编写代码。当我运行示例代码并编织时,它给了我以下错误:

*

Error running filter C:/Users/bbalamdari/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua:
...uments/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua:18: module 'pandoc.utils' not found:
    no field package.preload['pandoc.utils']
    no file 'C:\PROGRA~2\Pandoc\lua\pandoc\utils.lua'
    no file 'C:\PROGRA~2\Pandoc\lua\pandoc\utils\init.lua'
    no file 'C:\PROGRA~2\Pandoc\pandoc\utils.lua'
    no file 'C:\PROGRA~2\Pandoc\pandoc\utils\init.lua'
    no file 'C:\PROGRA~2\Pandoc\..\share\lua\5.3\pandoc\utils.lua'
    no file 'C:\PROGRA~2\Pandoc\..\share\lua\5.3\pandoc\utils\init.lua'
    no file '.\pandoc\utils.lua'
    no file '.\pandoc\utils\init.lua'
    no file 'C:\PROGRA~2\Pandoc\pandoc\utils.dll'
    no file 'C:\PROGRA~2\Pandoc\..\lib\lua\5.3\pandoc\utils.dll'
    no file 'C:\PROGRA~2\Pandoc\loadall.dll'
    no file '.\pandoc\utils.dll'
    no file 'C:\PROGRA~2\Pandoc\pandoc.dll'
    no file 'C:\PROGRA~2\Pandoc\..\lib\lua\5.3\pandoc.dll'
    no file 'C:\PROGRA~2\Pandoc\loadall.dll'
    no file '.\pandoc.dll'
Error: pandoc document conversion failed with error 83
Execution halted

*

我想也许我应该安装包“Pandoc.utils”,但是一旦我在 R 中调用了这个包,它就会给出这个错误:

包‘pandoc.utils’不可用(适用于 R 版本 3.6.0)

这是因为我有最新版本的 R 并且无法安装旧版本的 pandoc 吗?有谁知道怎么回事?

【问题讨论】:

    标签: html r rstudio r-markdown pandoc


    【解决方案1】:

    看起来 rmarkdown 找不到 pandoc。 RStudio 通常在your\path\to\Rstudio\bin\pandoc 中包含 pandoc 文件。当你打开 RStudio 时,它会偷偷设置一个名为 RSTUDIO_PANDOC 的环境变量,rmarkdown 使用它来查找 pandoc。

    运行命令Sys.getenv("RSTUDIO_PANDOC"),它将返回您的 pandoc 安装位置。如果不是,那很可能是您的问题。

    找到 RStudio 的安装位置后,您可以使用Sys.setenv(RSTUDIO_PANDOC = "your/path/to/Rstudio/bin/pandoc") 设置此环境变量。之后(假设这是您的问题)您应该能够按预期编织文档。

    【讨论】:

    • 感谢您的回答。它确实返回了位置,它位于“C:/Program Files/RStudio/bin/pandoc”中。问题看起来像“pandoc.utils”。不确定这是否是 pandoc 的额外或扩展,但是当我尝试安装时,它说不可用(对于 R 版本 3.6.0)
    • pandoc.utils 是作为 pandoc 一部分的模块的名称。它不是您需要安装的 R 包或任何东西。试试rmarkdown::pandoc_available(version = 2.7)。这应该返回TRUE。如果没有,可能值得尝试更新 RStudio(以及因此包含的 pandoc)
    • 或者自己试试installing pandoc。 pagebreak.lua 文件似乎在到处寻找要链接的 pandoc.dll 或 utils.dll,也许通过单独安装 pandoc 文件将在那里找到。
    【解决方案2】:

    我在我的 Windows 10 桌面上遇到了这个问题,并修复了它。

    如果您使用 Rstudio,在 R Markdown 终端中会有一个出现错误之前的长命令。它可能看起来像这样:

    "C:/Users/15510/AppData/Local/Pandoc/pandoc" ...

    而且它与我的Sys.getenv("RSTUDIO_PANDOC")不一致,即“C:/Program Files/RStudio/bin/pandoc/pandoc”

    所以我从Windows的系统环境中删除了我的pandoc路径(C:/Users/15510/AppData/Local/Pandoc/pandoc),然后rmd可以成功运行,终端说:

    "C:/Program Files/RStudio/bin/pandoc/pandoc" ...

    附:我猜你的用户目录下已经安装了pandoc,也许你可以检查一下你电脑的系统路径。

    【讨论】:

      【解决方案3】:

      不幸的是,以上方法都不适合我。令人惊讶的是,与互联网断开连接有所帮助。可能这也会对其他人有所帮助。

      【讨论】:

      • 你的意思是重启网络连接?
      • 不,保持与互联网的连接对我有用。
      猜你喜欢
      • 1970-01-01
      • 2019-03-07
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 2017-12-07
      • 1970-01-01
      相关资源
      最近更新 更多