将Rmarkdown文档编织为html / pdf失败

问题描述

我正在尝试将R markdown文件编织为html / pdf文档。这是我收到的错误消息:

output file: test.knit.md

pandoc.exe: test.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion Failed with error 1
Execution halted

No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: https://www.latex-project.org/get/

  If you are not sure,you may install TinyTeX in R: tinytex::install_tinytex()

  Otherwise consider MiKTeX on Windows - http://miktex.org

  MacTeX on macOS - https://tug.org/mactex/
  (NOTE: Download with Safari rather than Chrome _strongly_ recommended)

  Linux: Use system package manager

我正在使用R,Rstudio和tinytex软件包的最新版本,但是我不在网络驱动器上工作(即Rmd文件位于C:/)。

我重新安装了tinytex,这导致了一些错误消息:

tinytex::reinstall_tinytex()
If reinstallation fails,try install_tinytex() again. Then install the following packages:

tinytex::tlmgr_install(c("'\\ad.helsinki.fi\home\a\ann\Documents'","CMD.EXE was started with the above path as the current directory.","UNC paths are not supported.  Defaulting to Windows directory.","amsfonts","amsmath","atbegshi","atveryend","auxhook","babel","bibtex","bigintcalc","bitset","booktabs","cm","dehyph","dvipdfmx","dvips","ec","epstopdf-pkg","etex","etexcmds","etoolBox","euenc","fancyvrb","filehook","firstaid","float","fontspec","framed","geometry","gettitlestring","glyphlist","graphics","graphics-cfg","graphics-def","grffile","helvetic","hycolor","hyperref","hyph-utf8","hyphen-base","iftex","inconsolata","infwarerr","intcalc","knuth-lib","kpathsea","kvdefinekeys","kvoptions","kvsetkeys","l3backend","l3kernel","l3packages","latex","latex-amsmath-dev","latex-bin","latex-fonts","latex-tools-dev","latexconfig","latexmk","letltxmacro","lm","lm-math","ltxcmds","lua-alt-getopt","luahbtex","lualatex-math","lualibs","luaotfload","luatex","mdwtools","Metafont","mfware","modes","ms","natbib","path","pdfescape","pdftex","pdftexcmds","plain","refcount","rerunfilecheck","scheme-infraonly","stringenc","tex","tex-ini-files","texlive-scripts","texlive.infra","times","tipa","tlgs","tlperl","tlpsv","tools","unicode-data","unicode-math","uniquecounter","url","was","xcolor","xetex","xetexconfig","xkeyval","xunicode","zapfding"))

The directory C:\Users\ann\AppData\Roaming\TinyTeX/texmf-local is not empty. It will be backed up to C:\Users\ann\AppData\Local\Temp\RtmpWqoDNm\file1d1050f4326e and restored later.

tlmgr conf auxtrees remove "C:/PROGRA~1/R/R-40~1.3/share/texmf"
'\\ad.helsinki.fi\home\a\ann\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
'\\ad.helsinki.fi\home\a\ann\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
tlmgr conf auxtrees add "C:/PROGRA~1/R/R-40~1.3/share/texmf"
tlmgr install '\\ad.helsinki.fi\home\a\ann\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported.  Defaulting to Windows directory. path was
tlmgr.pl install: package '\\ad.helsinki.fi\home\a\ann\Documents' not present in repository.
tlmgr.pl install: package CMD.EXE not present in repository.
tlmgr.pl install: package Defaulting not present in repository.
tlmgr.pl install: package UNC not present in repository.
tlmgr.pl install: package Windows not present in repository.
tlmgr.pl install: package above not present in repository.
tlmgr.pl install: package are not present in repository.
tlmgr.pl install: package as not present in repository.
tlmgr.pl install: package current not present in repository.
tlmgr.pl install: package directory. not present in repository.
tlmgr.pl install: package not not present in repository.
tlmgr.pl install: package paths not present in repository.
tlmgr.pl install: package started not present in repository.
tlmgr.pl install: package supported. not present in repository.
tlmgr.pl install: package the not present in repository.
tlmgr.pl install: package to not present in repository.
tlmgr.pl install: package with not present in repository.
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/2,??:??/??:??] install: path [6k]
[2/2,00:00/00:00] install: was [4k]
tlmgr.pl: action install returned an error; continuing.
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: An error has occurred. See above messages. Exiting.
tlmgr.pl: package log updated: C:/Users/ann/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr update --self
tlmgr install '\\ad.helsinki.fi\home\a\ann\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported.  Defaulting to Windows directory. path was
tlmgr.pl install: package '\\ad.helsinki.fi\home\a\ann\Documents' not present in repository.
tlmgr.pl install: package CMD.EXE not present in repository.
tlmgr.pl install: package Defaulting not present in repository.
tlmgr.pl install: package UNC not present in repository.
tlmgr.pl install: package Windows not present in repository.
tlmgr.pl install: package above not present in repository.
tlmgr.pl install: package are not present in repository.
tlmgr.pl install: package as not present in repository.
tlmgr.pl install: package current not present in repository.
tlmgr.pl install: package directory. not present in repository.
tlmgr.pl install: package not not present in repository.
tlmgr.pl install: package paths not present in repository.
tlmgr.pl install: package started not present in repository.
tlmgr.pl install: package supported. not present in repository.
tlmgr.pl install: package the not present in repository.
tlmgr.pl install: package to not present in repository.
tlmgr.pl install: package with not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl install: package already present: path
tlmgr.pl install: package already present: was
tlmgr.pl: An error has occurred. See above messages. Exiting.

根据here中的建议,我试图验证R是否可以找到编织所需的程序。似乎找不到它们。

Sys.which('pdflatex')
pdflatex 
      "" 

此外,似乎还没有将tinytex路径添加到系统环境变量PATH中,因为在Sys.getenv('PATH')中找不到tinytex_root()路径(请参见例如here)。 / p>

tinytex::tinytex_root()
[1] "C:\\Users\\ann\\AppData\\Roaming\\TinyTeX"

 Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-4.0.3\\bin\\x64;C:\\Program Files\\ImageMagick-7.0.8-Q16;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\hriihima\\AppData\\Local\\Continuum\\anaconda3;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\physx\\Common;C:\\Program Files\\Git\\cmd;C:\\HYAPP\\rtools3.5\\bin;C:\\HYAPP\\rtools3.5\\gcc-4.6.3\\bin;C:\\HYAPP\\rtools3.5\\mingw_32\\bin;C:\\HYAPP\\rtools3.5\\mingw_64\\bin;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Common Files\\ThinPrint\\;C:\\Users\\ann\\AppData\\Local\\Microsoft\\WindowsApps;"

这是我的会话信息:

> xfun::session_info()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Locale:
  LC_COLLATE=Finnish_Finland.1252  LC_CTYPE=Finnish_Finland.1252    LC_MONETARY=Finnish_Finland.1252 LC_NUMERIC=C                    
  LC_TIME=Finnish_Finland.1252    

Package version:
  base64enc_0.1.3 compiler_4.0.3  digest_0.6.27   evaluate_0.14   glue_1.4.2      graphics_4.0.3  Grdevices_4.0.3 highr_0.8       htmltools_0.5.0
  jsonlite_1.7.1  knitr_1.30      magrittr_1.5    markdown_1.1    methods_4.0.3   mime_0.9        remotes_2.2.0   rlang_0.4.8     rmarkdown_2.5  
  stats_4.0.3     stringi_1.5.3   stringr_1.4.0   tinytex_0.26    tools_4.0.3     utils_4.0.3     xfun_0.18       yaml_2.2.1  

编辑:再次安装tinytex也无济于事,我从编织中得到了相同的错误消息。这是安装后打印的内容

tinytex::install_tinytex()
trying URL 'https://yihui.org/tinytex/TinyTeX-1.zip'
Content type 'application/octet-stream' length 99792951 bytes (95.2 MB)
downloaded 95.2 MB

tlmgr conf auxtrees add "C:/PROGRA~1/R/R-40~1.3/share/texmf"
tlmgr install path was
tlmgr.pl: package repository https://mirror.las.iastate.edu/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/2,00:01/00:01] install: was [4k]
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: package log updated: C:/Users/annvirkk/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log

安装MiKTeX之后,编织文档时不再看到Latex问题,但是与openBinaryFile相关的第一个错误仍然存​​在。这是我的示例Rmd脚本:

---
title: "test"
output:
  html_document: default
---

```{r setup,include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


testing

```{r}

print("hi")


### 1. Testing



```

这是它打印出来的错误消息:

output file: test.knit.md

pandoc.exe: test.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion Failed with error 1
Execution halted

我该如何解决这些问题以编制Rmarkdown文档?感谢您的帮助!

解决方法

也可以尝试安装Miketex,就像Edo所说的那样,像Rmarkdown建议的那样安装tinytex。

很明显,您的问题是未安装乳胶,所以只需尝试重新安装并安装另一个乳胶程序,您就可以编织好!

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...