I am trying to install the package called topicmodels in R and I have not had success. Here's what I have tried...
我试图在R中安装名为topicmodels的包,但我没有成功。这是我尝试过的……
Action: Install the package using install.packages("topicmodels")
操作:使用install.packages(“topicmodels”)安装包。
Result:
结果:
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)
So there I said okay let's install from source
我说好的,让我们从源代码安装。
Action: install.packages("/Users/my_name/Downloads/topicmodels_0.2-1.tar.gz",repos=NULL,type="source")
行动:install.packages(" /用户/ my_name /下载/ topicmodels_0.2 - 1. - tar.gz”,回购= NULL,类型=“源”)
Result:
结果:
* 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
So then I researched this gsl thing and came upon this link. And for the moment I thought all of my problems were gone and when I finally follow these directions. I get the following error (in the terminal)...
然后我研究了这个gsl的东西,然后找到了这个链接。就在那一刻,我觉得我所有的问题都消失了,当我最终听从这些指示的时候。我有以下错误(在终端)…
Warning in untar2(tarfile, files, list, exdir, restore_times) :
using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’
2 个解决方案
#1
18
First of all you have to install gsl
. Once you have that installed you can try to install the R package. You can download gsl from here (there you can pick the latest version gsl-latest.tar.gz
). Once it's been downloaded, install it by doing the following:
首先,你必须安装gsl。安装好后,可以尝试安装R包。您可以从这里下载gsl(在那里您可以选择最新版本的gsl-latest.tar.gz)。下载完成后,按以下步骤安装:
- Decompress the downloaded file (in my case the "latest" file contained this version:
gsl-1.16
) - 解压下载的文件(在我的例子中,“最新”文件包含了这个版本:gsl-1.16)
- Open the "Terminal"
- 打开“终端”
-
Then (using the Terminal), move inside the folder that you created on step 1. In my case I had the file on the folder called "Downloads", so I moved to the newly created folder by doing:
然后(使用终端),移动到您在第1步创建的文件夹中。在我的例子中,我将文件放在名为“下载”的文件夹中,所以我通过以下方式移动到新创建的文件夹:
cd Downloads/gsl-1.16
-
Once you are within that folder run the following commands (in order):
在该文件夹内运行以下命令(按顺序):
./configure make sudo make install
-
After doing it you won't get the previous error saying
fatal error: 'gsl/gsl_rng.h' file not found
, so you can try again the installation.在这样做之后,您将不会得到前面的错误,表示致命错误:“gsl/gsl_rng。”h'文件未找到,所以你可以再试一次安装。
-
Now go back to your R environment (e.g., RStudio) to try again to install the package by doing:
现在回到您的R环境(例如,RStudio),再次尝试安装包:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
I had the same problem, and after doing this I got the R package correctly installed, I hope it also works in your case.
我有同样的问题,在做了这个之后,我得到了正确安装的R包,我希望它也适用于你的情况。
#2
2
If you already using homebrew. It is better and faster to fix with variables than installing gsl manually from source.
如果你已经在使用homebrew了。与从源代码手动安装gsl相比,修复变量更好更快。
- Install gsl with homebrew
brew install gsl
- 安装gsl与自制的brew安装gsl。
-
Edit
~/.R/Makevars
and add.编辑~ /。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 -lgslcblasPKG_LIBS=-L/usr/local/opt/gettext/lib CFLAGS=-I/usr/local/opt/gsl/包括LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas。
#1
18
First of all you have to install gsl
. Once you have that installed you can try to install the R package. You can download gsl from here (there you can pick the latest version gsl-latest.tar.gz
). Once it's been downloaded, install it by doing the following:
首先,你必须安装gsl。安装好后,可以尝试安装R包。您可以从这里下载gsl(在那里您可以选择最新版本的gsl-latest.tar.gz)。下载完成后,按以下步骤安装:
- Decompress the downloaded file (in my case the "latest" file contained this version:
gsl-1.16
) - 解压下载的文件(在我的例子中,“最新”文件包含了这个版本:gsl-1.16)
- Open the "Terminal"
- 打开“终端”
-
Then (using the Terminal), move inside the folder that you created on step 1. In my case I had the file on the folder called "Downloads", so I moved to the newly created folder by doing:
然后(使用终端),移动到您在第1步创建的文件夹中。在我的例子中,我将文件放在名为“下载”的文件夹中,所以我通过以下方式移动到新创建的文件夹:
cd Downloads/gsl-1.16
-
Once you are within that folder run the following commands (in order):
在该文件夹内运行以下命令(按顺序):
./configure make sudo make install
-
After doing it you won't get the previous error saying
fatal error: 'gsl/gsl_rng.h' file not found
, so you can try again the installation.在这样做之后,您将不会得到前面的错误,表示致命错误:“gsl/gsl_rng。”h'文件未找到,所以你可以再试一次安装。
-
Now go back to your R environment (e.g., RStudio) to try again to install the package by doing:
现在回到您的R环境(例如,RStudio),再次尝试安装包:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
I had the same problem, and after doing this I got the R package correctly installed, I hope it also works in your case.
我有同样的问题,在做了这个之后,我得到了正确安装的R包,我希望它也适用于你的情况。
#2
2
If you already using homebrew. It is better and faster to fix with variables than installing gsl manually from source.
如果你已经在使用homebrew了。与从源代码手动安装gsl相比,修复变量更好更快。
- Install gsl with homebrew
brew install gsl
- 安装gsl与自制的brew安装gsl。
-
Edit
~/.R/Makevars
and add.编辑~ /。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 -lgslcblasPKG_LIBS=-L/usr/local/opt/gettext/lib CFLAGS=-I/usr/local/opt/gsl/包括LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas。