在rstudio OnAttach中启动OpenCPU时出错失败

时间:2016-11-12 12:10:33

标签: r opencpu

我正在尝试获取一个简单的OpenCPU应用程序(来自https://www.opencpu.org/download.html)。

由于我在AWS上使用Ubuntu,我按照Ubuntu的说明进行操作:

# Requires Ubuntu 14.04 (Trusty) or 16.04 (Xenial)
sudo add-apt-repository -y ppa:opencpu/opencpu-1.6
sudo apt-get update 
sudo apt-get upgrade

# Installs OpenCPU server
sudo apt-get install -y opencpu
# Done! Open http://yourhost/ocpu in your browser

# Optional: installs rstudio in http://yourhost/rstudio
sudo apt-get install -y rstudio-server 

顺利通过。

接下来,我尝试在Rstudio中安装软件包:

install.packages("opencpu")
Installing package into ‘/home/ruser/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/opencpu_1.6.1.tar.gz'
Content type 'unknown' length 563159 bytes (549 KB)
==================================================
downloaded 549 KB

* installing *source* package ‘opencpu’ ...
** package ‘opencpu’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (opencpu)

The downloaded source packages are in
    ‘/tmp/RtmpON3Ujv/downloaded_packages’
> library(opencpu)
Initiating OpenCPU server...
Using config: /home/ruser/.opencpu.conf
OpenCPU started.
[httpuv] http://myserver/rstudio/p/1529/ocpu
Error : .onAttach failed in attachNamespace() for 'opencpu', details:
  call: rhttpd$init()
  error: could not find function "startDynamicHelp"
Error: package or namespace load failed for ‘opencpu’

这是我收到错误的地方。尝试谷歌搜索错误,但没有运气。

1 个答案:

答案 0 :(得分:0)

@gaurav是对的。 opencpu上的说明非常容易让人误解,因为看起来它们显示的是一组指令,但事实上,R命令用于在交互式R会话中运行opencpu,而不是新安装的opencpu云服务器。

要在新的云服务器上运行示例应用程序(我假设您正在尝试这样做),您需要按照云服务器的说明进行操作。

以下是帮助我的云服务器文档的链接:

https://cran.r-project.org/web/packages/opencpu/vignettes/opencpu-server.pdf

具体来说,要运行示例应用程序,您需要以root身份启动R会话,并安装软件包:

sudo -i
R

#then from r session
library(devtools)
install_github("opencpu/gitstats")
install_github("opencpu/stocks")

#then quit
quit()

exit

然后重启opencpu服务:

sudo service opencpu restart

然后,您可以使用opencpu api导航到包。在Web浏览器中,转到:

http://localhost/ocpu/library/gitstats/www/

并且瞧 -