错误:需要一个“名称空间”文件。

时间:2021-10-09 19:39:06

I am trying to install some R packages on a Linux machine using

我正在尝试在Linux机器上安装一些R包。

R CMD INSTALL -l <ourRlibrarylocation> <path where I saved the packagename.tar.gz file>

and I see an error message:

我看到一个错误信息:

ERROR: a 'NAMESPACE' file is required

I am using R 3.0.1. Please help, I am new to R and just downloaded these packages for customers.

我用的是R 3.0.1。请帮忙,我刚到R,刚刚下载了这些包给客户。

One example:

一个例子:

 R CMD INSTALL -l /abcde/R/R-3.0.0/library /home/RFILES/PKG/UScensus2000tract_0.03.tar.gz
* installing *source* package âUScensus2000tractâ ...
ERROR: a 'NAMESPACE' file is required
* removing â/abcde/R/R-3.0.0/library/UScensus2000tractâ

3 个解决方案

#1


35  

According to the R documentation for writing extensions, all packages destined for version 3.0.0 and later must contain a NAMESPACE file. If you download an R package that gives you the above error, here's what you should try:

根据用于编写扩展的R文档,所有针对版本3.0.0和之后的包必须包含一个名称空间文件。如果你下载了一个以上错误的R包,下面是你应该尝试的:

Untar the package:

压缩包:

tar -xvf the_package.tar.gz

Add a NAMESPACE file with the line exportPattern( "." ):

添加一个带有行exportPattern的名称空间文件(“。”):

cd the_package
echo 'exportPattern( "." )' > NAMESPACE
cd ..

Re-tar the package:

Re-tar包:

tar -zcf the_package.tar.gz the_package

Try and install it again.

试着再安装一次。

Hope that helps.

希望有帮助。

#2


3  

I actually just hit the same thing when compiling R-3.0.1. It looks to be that the package version that I was using was out of date. This was for proto:

实际上我在编译R-3.0.1时碰到了同样的问题。看起来我使用的包版本已经过时了。这是原型:

# /var/local/R-3.0.1/bin/R CMD INSTALL -l /var/local/R-3.0.1/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package ‘proto’ ...
ERROR: a 'NAMESPACE' file is required
* removing ‘/var/local/R-3.0.1/lib64/R/library/proto’

But there was a newer version for proto (0.3-10) which worked fine:

但proto(0.3-10)的新版本运行良好:

# ../var/local/R-3.0.1/bin/R CMD INSTALL -l ../var/local/R-3.0.1/lib64/R/library proto_0.3-10.tar.gz
* installing *source* package ‘proto’ ...
** package ‘proto’ successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   ‘proto.Rnw’
   ‘protoref.Rnw’
** testing if installed package can be loaded
* DONE (proto)

I had an older install of R (2.15), which the older proto package worked with:

我有一个较老的R(2.15)安装,旧的proto包使用:

# /var/local/R-2.15.0/bin/R CMD INSTALL -l /var/local/R-2.15.0/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package 'proto' ...
** Creating default NAMESPACE file
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   'proto.Rnw'
   'protoref.Rnw'
** testing if installed package can be loaded

It looks like the older version of R actually creates the missing NAMESPACE file, but the new version bails. Hope this helps you!

看起来旧版本的R实际上创建了缺失的名称空间文件,但是新的版本是bails。希望这可以帮助你!

#3


1  

I found the following link more useful: How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

我发现下面的链接更有用:如何处理“package 'xxx”不可用(对于R版本x.y.z)“警告?”

6. The package is out of date

6。这个包裹已经过期了。

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).

它可能已经被归档(如果它不再被维护,不再通过rcmd检查测试)。

In this case, you can load an old version of the package using install_version()

在这种情况下,您可以使用install_version()加载一个旧版本的包

library(devtools)
install_version("foobarbaz", "0.1.2")

An alternative is to install from the github CRAN mirror.

另一种选择是安装github CRAN镜像。

library(devtools)
install_github("cran/foobarbaz")

#1


35  

According to the R documentation for writing extensions, all packages destined for version 3.0.0 and later must contain a NAMESPACE file. If you download an R package that gives you the above error, here's what you should try:

根据用于编写扩展的R文档,所有针对版本3.0.0和之后的包必须包含一个名称空间文件。如果你下载了一个以上错误的R包,下面是你应该尝试的:

Untar the package:

压缩包:

tar -xvf the_package.tar.gz

Add a NAMESPACE file with the line exportPattern( "." ):

添加一个带有行exportPattern的名称空间文件(“。”):

cd the_package
echo 'exportPattern( "." )' > NAMESPACE
cd ..

Re-tar the package:

Re-tar包:

tar -zcf the_package.tar.gz the_package

Try and install it again.

试着再安装一次。

Hope that helps.

希望有帮助。

#2


3  

I actually just hit the same thing when compiling R-3.0.1. It looks to be that the package version that I was using was out of date. This was for proto:

实际上我在编译R-3.0.1时碰到了同样的问题。看起来我使用的包版本已经过时了。这是原型:

# /var/local/R-3.0.1/bin/R CMD INSTALL -l /var/local/R-3.0.1/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package ‘proto’ ...
ERROR: a 'NAMESPACE' file is required
* removing ‘/var/local/R-3.0.1/lib64/R/library/proto’

But there was a newer version for proto (0.3-10) which worked fine:

但proto(0.3-10)的新版本运行良好:

# ../var/local/R-3.0.1/bin/R CMD INSTALL -l ../var/local/R-3.0.1/lib64/R/library proto_0.3-10.tar.gz
* installing *source* package ‘proto’ ...
** package ‘proto’ successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   ‘proto.Rnw’
   ‘protoref.Rnw’
** testing if installed package can be loaded
* DONE (proto)

I had an older install of R (2.15), which the older proto package worked with:

我有一个较老的R(2.15)安装,旧的proto包使用:

# /var/local/R-2.15.0/bin/R CMD INSTALL -l /var/local/R-2.15.0/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package 'proto' ...
** Creating default NAMESPACE file
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   'proto.Rnw'
   'protoref.Rnw'
** testing if installed package can be loaded

It looks like the older version of R actually creates the missing NAMESPACE file, but the new version bails. Hope this helps you!

看起来旧版本的R实际上创建了缺失的名称空间文件,但是新的版本是bails。希望这可以帮助你!

#3


1  

I found the following link more useful: How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

我发现下面的链接更有用:如何处理“package 'xxx”不可用(对于R版本x.y.z)“警告?”

6. The package is out of date

6。这个包裹已经过期了。

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).

它可能已经被归档(如果它不再被维护,不再通过rcmd检查测试)。

In this case, you can load an old version of the package using install_version()

在这种情况下,您可以使用install_version()加载一个旧版本的包

library(devtools)
install_version("foobarbaz", "0.1.2")

An alternative is to install from the github CRAN mirror.

另一种选择是安装github CRAN镜像。

library(devtools)
install_github("cran/foobarbaz")

相关文章