我一直在尝试从Sagemaker Jupyter Notebook实例建立与Teradata的连接。我试图通过R Studio来实现。但是,无论何时我尝试在实例中安装软件包,都会收到非零的退出状态错误。
我尝试安装以下方式:
remotes::install_github()
或
devtools::install_github()
以及:
install.packages('odbc', repo="https://cran.rstudio.com/")
我尝试过使用RODBC进行相同的操作,并且收到相同的警告或错误。
关于如何解决这个问题的任何想法?
提前感谢。
更新:如果我运行以下代码行:
devtools::install_github("r-dbi/odbc")`
我收到以下错误(这只是摘录):
Error: Failed to install 'odbc' from GitHub:
System command error, exit status: 1, stdout + stderr (last 10 lines):
E> ** testing if installed package can be loaded from temporary location
E> Error: package or namespace load failed for ‘odbc’ in dyn.load(file, DLLpath = DLLpath, ...):
E> unable to load shared object '/tmp/RtmpBuMhbW/Rinst32846cdd20a9/00LOCK-odbc/00new/odbc/libs/odbc.so':
E> libodbc.so.2: cannot open shared object file: No such file or directory
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing ‘/tmp/RtmpBuMhbW/Rinst32846cdd20a9/odbc’
E> -----------------------------------
E> ERROR: package installation failed
Traceback:
好吧,在阅读了AWS / Sagemaker / Conda / R文档数小时后,我得出的结论是,我不知道如何解释这种现象。
尽管如此,我已经找到了解决方法!
因此,我们知道如何通过Jupyter终端或直接从ipynb文件中的单元安装软件包。但是,如果您尝试像在终端机或python内核中那样在R内核中运行这些命令,则会遇到错误。
而且,对于某些在终端中甚至在python内核上安装它的人,可能只是使conda在其他环境中安装了该软件包。是的,事实证明您的Jupyter实例上有几个环境。
所以,要讲到重点,就像我说的那样,您将使用conda install命令,而不是pip,sudo或yum命令。
让您的生活更轻松。 Anywasy这是您需要在R内核单元上运行的代码,如果install.packages和install_github无法正常工作,则需要将软件包直接安装到正确的环境中:
system(command = 'conda install -c r packageName --yes')
示例:
system(command = 'conda install -c r tidyverse --yes')
就这样。之后,您可以调用library()并照常继续执行R工作流程。
希望对大家有帮助!