简体   繁体   English

尝试编织 Rmarkdown 但出现 pandoc.utils 错误或 pandoc 错误 83

[英]Trying to knit Rmarkdown but getting pandoc.utils error or pandoc error 83

I am new to Rmarkdown and trying to learn how to knit a code.我是 Rmarkdown 的新手,正在尝试学习如何编写代码。 when I run the sample code and knit, it gives me the following error:当我运行示例代码并编织时,它给了我以下错误:

* *

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

* *

I thought perhaps I should install package"Pandoc.utils" but once I called the package in R, it gave this error:我想也许我应该安装包“Pandoc.utils”,但是一旦我在 R 中调用了这个包,它就会出现这个错误:

package 'pandoc.utils' is not available (for R version 3.6.0)包“pandoc.utils”不可用(对于 R 版本 3.6.0)

Is this because I have the latest version of R and it cant install the older version of pandoc?这是因为我有最新版本的 R 并且它无法安装旧版本的 pandoc 吗? does anyone know what is going on?有谁知道发生了什么?

It looks like rmarkdown can't find pandoc.看起来 rmarkdown 找不到 pandoc。 RStudio typically includes the pandoc files in your\\path\\to\\Rstudio\\bin\\pandoc . RStudio 通常在your\\path\\to\\Rstudio\\bin\\pandoc包含 pandoc 文件。 When you open RStudio, it secretly sets an environment variable named RSTUDIO_PANDOC which rmarkdown uses to find pandoc.当您打开 RStudio 时,它会秘密设置一个名为RSTUDIO_PANDOC的环境变量,rmarkdown 使用该变量来查找 pandoc。

Run the command Sys.getenv("RSTUDIO_PANDOC") , which should return the location of your pandoc installation.运行命令Sys.getenv("RSTUDIO_PANDOC") ,它应该返回您的 pandoc 安装位置。 If it doesn't, that is likely to be your problem.如果没有,那很可能是你的问题。

Once you find where RStudio is installed, you can set this environment variable with Sys.setenv(RSTUDIO_PANDOC = "your/path/to/Rstudio/bin/pandoc") .找到 RStudio 的安装位置后,您可以使用Sys.setenv(RSTUDIO_PANDOC = "your/path/to/Rstudio/bin/pandoc")设置此环境变量。 After that (assuming this is your problem) you should be able to knit the document as expected.之后(假设这是您的问题)您应该能够按预期编织文档。

I had this problem at my Windows 10 desktop, and fixed it.我在 Windows 10 桌面上遇到了这个问题,并修复了它。

There is a long command before your error in the R Markdown terminal if you use Rstudio.如果您使用 Rstudio,在 R Markdown 终端中出现错误之前有一个很长的命令 It may looks like this:它可能看起来像这样:

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

And it is inconsistent with my Sys.getenv("RSTUDIO_PANDOC") , which is "C:/Program Files/RStudio/bin/pandoc/pandoc"我的Sys.getenv("RSTUDIO_PANDOC")不一致,即“C:/Program Files/RStudio/bin/pandoc/pandoc”

So I remove my pandoc path(C:/Users/15510/AppData/Local/Pandoc/pandoc) from the system environment in Windows, and then the rmd can run successfully with the terminal saying this:所以我从Windows的系统环境中删除了我的pandoc路径(C:/Users/15510/AppData/Local/Pandoc/pandoc),然后rmd可以成功运行,终端说:

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

PS I guess you have installed pandoc in your user directory, maybe you can check your system path of the computer. PS我猜你已经在你的用户目录中安装了pandoc,也许你可以检查你的计算机系统路径。

Unfortunately, none of the above worked for me.不幸的是,以上都不适合我。 Surprisingly, disconnecting from the internet helped.令人惊讶的是,断开与互联网的连接有所帮助。 May be this will help someone else too.可能这也会帮助别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM