首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将Rmarkdown文档编成html/pdf失败

将Rmarkdown文档编成html/pdf失败
EN

Stack Overflow用户
提问于 2020-10-29 11:49:22
回答 1查看 1.3K关注 0票数 2

我正在尝试将一个R标记文件编织到html/pdf文档中。这是我得到的错误消息:

代码语言:javascript
复制
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,这导致了一些错误消息:

代码语言:javascript
复制
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.

根据这里中的建议,我试图验证R是否能找到编织所需的程序。看来它找不到它们。

代码语言:javascript
复制
Sys.which('pdflatex')
pdflatex 
      "" 

此外,似乎没有将tinytex路径添加到系统环境变量路径中,因为tinytex_root()路径没有在Sys.getenv(“path”)中找到(参见这里)。

代码语言:javascript
复制
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;"

这是我的会话信息:

代码语言:javascript
复制
> 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也无济于事,我从编织中得到了同样的错误消息。以下是安装后打印的内容:

代码语言:javascript
复制
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, ??:??/??:??] install: path [6k]
[2/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脚本:

代码语言:javascript
复制
---
title: "test"
output:
  html_document: default
---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo =真)

代码语言:javascript
复制
testing

```{r}

印刷品(“嗨”)

1.测试

代码语言:javascript
复制

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

代码语言:javascript
复制
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文档?谢谢你帮忙!

EN

回答 1

Stack Overflow用户

发布于 2020-10-29 13:44:18

也可以试着安装Miketex,也可以像江户所说的,安装像Rmarkdown建议的小提花。

很明显,您的问题只是乳胶没有安装,所以只要尝试重新安装和安装另一个乳胶程序,你应该是好的编织!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64590509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档