我正在尝试在R中安装名为topicmodels的包,但我没有成功.这是我试过的......
操作:使用安装包 install.packages("topicmodels")
结果:
package ‘topicmodels’ is available as a source package but not as a binary Warning in install.packages : package ‘topicmodels’ is not available (for R version 3.1.0)
所以我说好了让我们从源码安装
行动:
install.packages("/Users/my_name/Downloads/topicmodels_0.2-1.tar.gz",repos=NULL,type="source")
结果:
* installing *source* package ‘topicmodels’ ... ** package ‘topicmodels’ successfully unpacked and MD5 sums checked ** libs clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c cokus.c -o cokus.o clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c common.c -o common.o clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c ctm.c -o ctm.o ctm.c:29:10: fatal error: 'gsl/gsl_rng.h' file not found include gsl/gsl_rng.h 1 error generated. make: *** [ctm.o] Error 1 ERROR: compilation failed for package ‘topicmodels’ * removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/topicmodels’ Warning in install.packages : installation of package ‘/Users/me/Downloads/topicmodels_0.2-1.tar.gz’ had non-zero exit status
那么我研究了这个gsl的东西并且发现了这个链接.目前我认为我的所有问题都已消失,当我最终遵循这些指示时.我收到以下错误(在终端)...
Warning in untar2(tarfile, files, list, exdir, restore_times) : using pax extended headers ERROR: cannot extract package from ‘topicmodels.tar.gz’
小智.. 23
首先,你必须安装gsl
.安装完成后,可以尝试安装R软件包.你可以从这里下载gsl (你可以选择最新版本gsl-latest.tar.gz
).下载完成后,通过执行以下操作进行安装:
解压下载的文件(在我的情况"最新"文件包含在此版本:gsl-1.16
)
打开"终端"
然后(使用终端),移动你在步骤1中创建的文件夹.在我的情况下,我将文件放在名为"Downloads"的文件夹中,所以我通过执行以下操作移动到新创建的文件夹:
cd Downloads/gsl-1.16
进入该文件夹后,运行以下命令(按顺序):
./configure make sudo make install
执行此操作后,您将无法获得先前的错误说明fatal error: 'gsl/gsl_rng.h' file not found
,因此您可以再次尝试安装.
现在回到你的R环境(例如,RStudio)再次尝试安装包:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
我遇到了同样的问题,在这之后我正确地安装了R包,我希望它也适用于你的情况.
如果您已经在使用自制软件。与从源代码手动安装gsl相比,使用变量修复更好,更快。
用自制软件安装gsl brew install gsl
编辑~/.R/Makevars
并添加。
PKG_LIBS = -L / usr / local / opt / gettext / lib
CFLAGS = -I / usr / local / opt / gsl / include
LDFLAGS = -L / usr / local / opt / gsl / lib -lgsl -lgslcblas
首先,你必须安装gsl
.安装完成后,可以尝试安装R软件包.你可以从这里下载gsl (你可以选择最新版本gsl-latest.tar.gz
).下载完成后,通过执行以下操作进行安装:
解压下载的文件(在我的情况"最新"文件包含在此版本:gsl-1.16
)
打开"终端"
然后(使用终端),移动你在步骤1中创建的文件夹.在我的情况下,我将文件放在名为"Downloads"的文件夹中,所以我通过执行以下操作移动到新创建的文件夹:
cd Downloads/gsl-1.16
进入该文件夹后,运行以下命令(按顺序):
./configure make sudo make install
执行此操作后,您将无法获得先前的错误说明fatal error: 'gsl/gsl_rng.h' file not found
,因此您可以再次尝试安装.
现在回到你的R环境(例如,RStudio)再次尝试安装包:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
我遇到了同样的问题,在这之后我正确地安装了R包,我希望它也适用于你的情况.