0

R 3.6.1在 Anaconda 环境中运行(它不会让我升级到 v4)并尝试安装semPlot以配合lavaan安装好的。以下是我安装的软件包:

library(psych)   # for Chronbach's alpha calculation
library(psychTools)
library(lavaan)
library(knitr)
library(tidyverse)
library(haven)
library(labelled)
library(kableExtra)
library(survey)
library(srvyr)
library(scales)

我尝试了许多不同的安装方式semPlot,最新的是直接来自 github 存储库:SachaEpskamp/semPlot,stackoverflow 上的一个人说这对他们有用。在我的控制台上滚动了大约 10,000 行警告和错误之后,我无法跟踪其中的大部分内容,最新的尝试最终产生了这个结果:

The downloaded source packages are in
    ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
✓  checking for file ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/remotes164e53982f159/SachaEpskamp-semPlot-a2ee9df/DESCRIPTION’ ...
─  preparing ‘semPlot’:
✓  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘semPlot_1.1.4.tar.gz’
   
ERROR: dependency ‘OpenMx’ is not available for package ‘semPlot’
* removing ‘/Users/sjgenco/opt/anaconda3/envs/r_env/lib/R/library/semPlot’
Warning messages:
1: In i.p(...) : installation of package ‘OpenMx’ had non-zero exit status
2: In i.p(...) :
  installation of package ‘/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T//RtmpvagRhg/file164e543b3278e/semPlot_1.1.4.tar.gz’ had non-zero exit status

我不知道是否OpenMx是罪魁祸首,或者是否OpenMX可能semPlot遇到同样的问题,但是当我尝试安装它时,我得到了同样的结果......之前的数千行(以及大约 20 分钟无结果的运行时间)它只是逐渐消失,没有任何错误,只是“非零退出状态”。

我在这里阅读了很多关于 SO 的类似问题,但大多数都没有找到一些依赖包,比如glassoXML缺少 fortran 编译器,但我的输出中没有类似的引用,无论如何我都安装了所有这些包。我只有大量这样的输出(这是来自失败的OpenMx安装尝试:

In file included from povRAM.cpp:2:
In file included from ./omxExpectation.h:32:
In file included from ./omxDefines.h:21:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/RcppCommon.h:120:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/proxy.h:22:
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
        NamesProxy& operator=(const NamesProxy& rhs) {
                    ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:83:16: note: in implicit copy constructor for 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::NamesProxy' first required here
        return NamesProxy( static_cast<CLASS&>(*this) ) ;
               ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/api/meat/module/Module.h:35:11: note: in instantiation of member function 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::names' requested here
            info.names() = names ;
                 ^
In file included from povRAM.cpp:3:
In file included from ./path.h:6:
./polynomial.h:26:2: warning: definition of implicit copy assignment operator for 'Monomial<double>' is deprecated because it has a user-declared copy constructor [-Wdeprecated-copy]
        Monomial(const Monomial<F> &from) { coeff = from.coeff; exponent = from.exponent; }
        ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1691:39: note: in implicit copy assignment operator for 'Monomial<double>' first required here
            __cache.__get()->__value_ = *__first;
                                      ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1648:9: note: in instantiation of function template specialization 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::__assign_multi<std::__1::__tree_const_iterator<Monomial<double>, std::__1::__tree_node<Monomial<double>, void *> *, long> >' requested here
        __assign_multi(__t.begin(), __t.end());
        ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/set:538:21: note: in instantiation of member function 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
            __tree_ = __s.__tree_;
                    ^
./polynomial.h:183:13: note: in instantiation of member function 'std::__1::set<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
                monomials = erg.monomials;
                          ^
povRAM.cpp:299:16: note: in instantiation of member function 'Polynomial<double>::operator+=' requested here
                        polyRep[nn] += term;
                                    ^
95 warnings and 7 errors generated.
make: *** [/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/etc/Makeconf:175: povRAM.o] Error 1
ERROR: compilation failed for package ‘OpenMx’
* removing ‘/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/OpenMx’
Warning in install.packages :
  installation of package ‘OpenMx’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/Rtmp8fpYnY/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

在所有这些输出中一次又一次出现的警告是:

warning: definition of implicit copy constructor ...

如:

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
        NamesProxy& operator=(const NamesProxy& rhs) {
                    ^

或这个

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/AttributeProxy.h:33:25: warning: definition of implicit copy constructor for 'AttributeProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
            AttributeProxy& operator=(const AttributeProxy& rhs){
                            ^

或这个

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/RcppEigen/include/Eigen/src/SparseCore/SparsePermutation.h:162:1: note: candidate template ignored: could not match 'InverseImpl' against 'Transpose'
operator*(const SparseMatrixBase<SparseDerived>& matrix, const InverseImpl<PermutationType, PermutationStorage>& tperm)
^
povRAM.cpp:157:24: error: use of undeclared identifier 'curProd'
                        if (tx == 1) prev = curProd.nonZeros();
                                            ^

这只是一个大混乱,我不知道发生了什么,为什么,或者该怎么做。有什么想法吗?

4

2 回答 2

1

感谢您提供详细的建议。首先,我尝试通过conda forge从终端在我的 r_env 中运行安装来在我的 Anaconda 环境中修复它。它安装了,但它也设法破坏了我的 RStudio 安装,因此它不再打开。好的,吸取教训。我删除了我在 Anaconda 中的整个 r_env 并继续按照 @MrFlick 的建议从他们的官方下载站点安装全新的 R 和 RStudio 版本。当我打开我的新 RStudio 应用程序时,我能够安装semPlot,它安装了它的依赖OpenMx项没有任何障碍。回到工作。

于 2021-06-30T18:22:46.410 回答
1

您的问题可能是由通过 Anaconda 运行 R 引起的。按照这些步骤,我成功地在 macOS 11.4 / Rv4.0 上安装了 OpenMX 和 semPlot,并且没有出现错误,但是您必须尝试它来确定它们是否可以在“conda”R3.6.3 上运行。

  1. 从应用商店安装 xcode(安装 xcode 的说明),然后从终端安装/重新安装 xcode 命令行工具:
# To delete an existing command line tools installation:
sudo rm -rf /Library/Developer/CommandLineTools

# To install the command line tools
sudo xcode-select --install
  1. 通过 Homebrew 安装 gcc 和 llvm(安装 Homebrew 的说明),或者,如果您已经安装了 gcc 和 llvm,请跳到第 3 步。
# WARNING: This can take several hours
brew install gcc
brew install llvm
  1. 如果您已经通过 Homebrew 安装了 gcc 和 llvm:
brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
  1. 将一些标题链接到 /usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

# You can ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
  1. 检查您的 gfortran ( cd /usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/; ls) 版本,然后编辑您的文件(如果您的目录或 'conda' R 等效目录中~/.R/Makevars没有调用文件,请创建它)并仅包含以下行:Makevars~/.R/
LOC = /usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

# (check that the version of gfortran - in this case 10.2.0 - matches the version specified in FLIBS)
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++
  1. 打开 R 并安装软件包(当被询问时,从 source = "Yes" 编译):
install.packages("qgraph")
install.packages("OpenMx")
devtools::install_github("SachaEpskamp/semPlot")

然后,希望事情会按预期加载。

于 2021-06-30T05:11:14.540 回答