【发布时间】:2013-02-04 18:15:33
【问题描述】:
我问了一个相关问题:check if a program is installed
但在我在所有三个系统上为自己测试了解决方案之前,我不会回答。我可以让 pandoc 在 Windows 机器上的 R 中工作,但在 linux 上,我从 R 终端收到每个方法的错误/响应:
1:
> system('pandoc -v')
sh: 1: pandoc: not found
2:
> myPaths <- c("pandoc",
+ "~/.cabal/bin/pandoc",
+ "~/Library/Haskell/bin/pandoc",
+ "C:\\PROGRA~1\\Pandoc\\bin\\pandoc")
> Sys.which(myPaths)
pandoc ~/.cabal/bin/pandoc
"" "/home/tyler/.cabal/bin/pandoc"
~/Library/Haskell/bin/pandoc C:\\PROGRA~1\\Pandoc\\bin\\pandoc
"" ""
3:
> Sys.which("pandoc")
pandoc
""
您可能认为我没有安装 pandoc,但我相信我有。从干净的终端会话:
> tyler@trinker ~ $ echo $PATH
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/tyler/.cabal/bin
和
tyler@trinker ~ $ pandoc -v
pandoc 1.10.1
Compiled with citeproc-hs 0.3.7, texmath 0.6.1.3, highlighting-kate 0.5.3.6.
Syntax highlighting is supported for the following languages:
Actionscript, Ada, Alert, Alert_indent, Apache, Asn1, Asp, Awk, Bash,
Bibtex, Boo, C, Changelog, Clojure, Cmake, Coffee, Coldfusion, Commonlisp,
Cpp, Cs, Css, Curry, D, Diff, Djangotemplate, Doxygen, Doxygenlua, Dtd,
Eiffel, Email, Erlang, Fortran, Fsharp, Gnuassembler, Go, Haskell, Haxe,
Html, Ini, Java, Javadoc, Javascript, Json, Jsp, Julia, Latex, Lex,
LiterateCurry, LiterateHaskell, Lua, Makefile, Mandoc, Matlab, Maxima,
Metafont, Mips, Modula2, Modula3, Monobasic, Nasm, Noweb, Objectivec,
Objectivecpp, Ocaml, Octave, Pascal, Perl, Php, Pike, Postscript, Prolog,
Python, R, Relaxngcompact, Rhtml, Ruby, Scala, Scheme, Sci, Sed, Sgml, Sql,
SqlMysql, SqlPostgresql, Tcl, Texinfo, Verilog, Vhdl, Xml, Xorg, Xslt, Xul,
Yacc, Yaml
Copyright (C) 2006-2013 John MacFarlane
Web: http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
如何让 Linux Mint 上的 R 识别 pandoc?(我是 Linux 新手)
【问题讨论】:
-
在 Ubuntu 12.04 上为我工作。但是我在 /usr/bin/ 中有 pandoc。
-
迪托。
system("which pandoc")返回/usr/bin/pandoc。我认为您在那里使某些事情过于复杂。这不是 Windows。一旦你安装了一个二进制文件,“它就在那里”。 -
我试图通过 cabal 更新使用更新版本的 pandoc,如 here 所示。然而它在那个页面上说它把它放在
~/.cabal/bin。我想如果我将这些文件放到usr目录中,它会按预期工作,但我什至不知道在哪里可以找到 usr 目录。但是使用sudo apt-get install pandoc它现在可以在 R 上运行。 -
@DirkEddelbuettel 就像 Tyler 提到的,如果你通过 cabal 安装最新版本,它不在 /usr/bin 中。 Tyler - 当 R 无法通过 Sys.which 找到 pandoc 时,您是在使用 RStudio,还是只是在使用终端?对我来说,它适用于终端,但不适用于 RStudio。似乎 RStudio 没有在 .bashrc 中读取,所以使用 RStudio 时 ~/.cabal/bin 不在您的路径中。
-
@TylerRinker,我不明白。我建议的解决方案检测到 Pandoc。它只是意味着当你编写一个 Pandoc 系统调用时,你不能只做类似
system("pandoc -o etc...")的事情,而必须做类似system("~/.cabal/bin/pandoc -o etc...")的事情,换句话说,你需要修改系统调用以使用完整路径。
标签: r pandoc linux-mint