2016-05-04 35 views
4

我在命令行推出的R和鍵入以下內容:無法與R包安裝,由於XML的依賴性不匹配

install.packages("XML") 

選擇一個鏡像站點之後,我看到了下面的輸出:

trying URL 'https://cloud.r-project.org/src/contrib/XML_3.98-1.4.tar.gz' 
Content type 'application/x-gzip' length 1599214 bytes (1.5 MB) 
================================================== 
downloaded 1.5 MB 

* installing *source* package ‘XML’ ... 
** package ‘XML’ successfully unpacked and MD5 sums checked 
checking for gcc... gcc 
checking for C compiler default output file name... a.out 
checking whether the C compiler works... yes 
checking whether we are cross compiling... no 
checking for suffix of executables... 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
checking how to run the C preprocessor... gcc -E 
checking for sed... /usr/local/Library/ENV/4.3/sed 
checking for pkg-config... /usr/local/bin/pkg-config 
checking for xml2-config... /Users/richiethomas/anaconda/bin/xml2-config 
USE_XML2 = yes 
SED_EXTENDED_ARG: -E 
Minor 9, Patch 2 for 2.9.2 
Located parser file -I/Users/richiethomas/anaconda/include/libxml2/parser.h 
Checking for 1.8: -I/Users/richiethomas/anaconda/include/libxml2 
Using libxml2.* 
checking for gzopen in -lz... yes 
checking for xmlParseFile in -lxml2... yes 
You are trying to use a version 2.* edition of libxml 
but an incompatible library. The header files and library seem to be 
mismatched. If you have specified LIBXML_INCDIR, make certain to also 
specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default 
directories. 
ERROR: configuration failed for package ‘XML’ 
* removing ‘/usr/local/lib/R/3.2/site-library/XML’ 

The downloaded source packages are in 
    ‘/private/var/folders/jy/0cwn40p951xc7f1480z3sxzm0000gn/T/RtmpvWMrkH/downloaded_packages’ 
Warning message: 
In install.packages("XML") : 
    installation of package ‘XML’ had non-zero exit status 

我搜索了一下,發現this link,它建議在命令行中運行'which xmllint'命令來查找可能與R相沖突的任何XML安裝。當我跑它的輸出是:

/Users/richiethomas/anaconda/bin/xmllint 

糾正我,如果我錯了,但現在看來,我的Python安裝具有衝突與一個R要下載一個XML的依賴。這是正確的嗎?如果是這樣,我該如何解決它,以便Python和R都安裝在我的機器上?

編輯:我正在使用OSX。我跑了「brew install libxml2」,但Homebrew說它已經安裝好了。

編輯#2:我試圖通過自制程序卸載並重新安裝R,我仍然得到相同的錯誤。編輯#3:我運行了「brew info libxml2」,看到有一個「--with-python」標誌,它可以啓用Python支持的構建。我也注意到以下幾點:

Generally there are no consequences of this for you. If you build your 
own software and it requires this formula, you'll need to add to your 
build variables: 

    LDFLAGS: -L/usr/local/opt/libxml2/lib 
    CPPFLAGS: -I/usr/local/opt/libxml2/include 

我跑了「BREW卸載libxml2的」,然後「釀造安裝的libxml2 --with-蟒蛇」,然後使用「導出」命令設定上述2的環境變量。然後我重新運行R並再次嘗試安裝XML包。只見幾十個「路過的說法在這裏參數」(見下文)類型的警告,接着一個非零退出代碼:

* installing *source* package ‘XML’ ... 
** package ‘XML’ successfully unpacked and MD5 sums checked 
checking for gcc... gcc 
checking for C compiler default output file name... a.out 
checking whether the C compiler works... yes 
checking whether we are cross compiling... no 
checking for suffix of executables... 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
checking how to run the C preprocessor... gcc -E 
checking for sed... /usr/local/Library/ENV/4.3/sed 
checking for pkg-config... /usr/local/bin/pkg-config 
checking for xml2-config... /Users/richiethomas/anaconda/bin/xml2-config 
USE_XML2 = yes 
SED_EXTENDED_ARG: -E 
Minor 9, Patch 2 for 2.9.2 
Located parser file -I/Users/richiethomas/anaconda/include/libxml2/parser.h 
Checking for 1.8: -I/Users/richiethomas/anaconda/include/libxml2 
Using libxml2.* 
checking for gzopen in -lz... yes 
checking for xmlParseFile in -lxml2... yes 
checking for xmlHashSize in -lxml2... yes 
Using built-in xmlHashSize 
Checking DTD parsing (presence of externalSubset)... 
checking for xmlHashSize in -lxml2... yes 
Found xmlHashSize 
checking for xmlOutputBufferCreateBuffer in -lxml2... yes 
have xmlOutputBufferCreateBuffer() 
checking for xmlDocDumpFormatMemoryEnc in -lxml2... yes 
checking libxml/xmlversion.h usability... yes 
checking libxml/xmlversion.h presence... yes 
checking for libxml/xmlversion.h... yes 
Expat: FALSE 
Checking for return type of xmlHashScan element routine. 
No return value for xmlHashScan 
xmlNs has a context field 
Checking for cetype_t enumeration 
Using recent version of R with cetype_t enumeration type for encoding 
checking for xmlsec1-config... no 
nodegc default 
xml-debug default 
Version has XML_WITH_ZLIB 
Version has xmlHasFeature() 

**************************************** 
Configuration information: 

Libxml settings 

libxml include directory: -I/Users/richiethomas/anaconda/include/libxml2 
libxml library directory: -L/Users/richiethomas/anaconda/lib -lxml2 -lz -liconv -lm -lz -lxml2 
libxml 2:     -DLIBXML2=1 

Compilation flags:   -DLIBXML -I/Users/richiethomas/anaconda/include/libxml2 -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DDUMP_WITH_ENCODING=1 -DUSE_XML_VERSION_H=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DNO_XML_HASH_SCANNER_RETURN=1 -DLIBXML_NAMESPACE_HAS_CONTEXT=1 -DHAVE_R_CETYPE_T=1 -DHAVE_XML_WITH_ZLIB=1 -DHAVE_XML_HAS_FEATURE=1 -DUSE_R=1 -D_R_=1 -DHAVE_VALIDITY=1 -DXML_REF_COUNT_NODES=1 
Link flags:    -L/Users/richiethomas/anaconda/lib -lxml2 -lz -liconv -lm -lz -lxml2 

**************************************** 
configure: creating ./config.status 
config.status: creating src/Makevars 
config.status: creating R/supports.R 
config.status: creating inst/scripts/RSXML.csh 
config.status: creating inst/scripts/RSXML.bsh 
** libs 
clang -I/usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include -DNDEBUG -DLIBXML -I/Users/richiethomas/anaconda/include/libxml2 -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DDUMP_WITH_ENCODING=1 -DUSE_XML_VERSION_H=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DNO_XML_HASH_SCANNER_RETURN=1 -DLIBXML_NAMESPACE_HAS_CONTEXT=1 -DHAVE_R_CETYPE_T=1 -DHAVE_XML_WITH_ZLIB=1 -DHAVE_XML_HAS_FEATURE=1 -DUSE_R=1 -D_R_=1 -DHAVE_VALIDITY=1 -DXML_REF_COUNT_NODES=1 -I. -DLIBXML2=1 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -fPIC -g -O2 -c DocParse.c -o DocParse.o 
DocParse.c:375:60: warning: passing 'const char *' to parameter of type 'const xmlChar *' (aka 'const unsigned char *') converts between 
     pointers to integer types with different sign [-Wpointer-sign] 
    SET_STRING_ELT(VECTOR_ELT(rdoc, FILE_ELEMENT_NAME), 0, ENC_COPY_TO_USER_STRING(doc->name ? XMLCHAR_TO_CHAR(doc->name) : fileName)); 
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
./Utils.h:235:74: note: expanded from macro 'ENC_COPY_TO_USER_STRING' 
#define ENC_COPY_TO_USER_STRING(x) CreateCharSexpWithEncoding(encoding, CHAR_TO_XMLCHAR (x)) 
                     ^~~~~~~~~~~~~~~~~~~ 
./Utils.h:12:31: note: expanded from macro 'CHAR_TO_XMLCHAR' 
#define CHAR_TO_XMLCHAR(val) ((xmlChar *) val) 
           ^~~~~~~~~~~~~~~~~ 
./Utils.h:220:73: note: passing argument to parameter 'str' here 
SEXP CreateCharSexpWithEncoding(const xmlChar *encoding, const xmlChar *str); 

..... 

/usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include/Rinternals.h:822:28: note: passing argument to parameter here 
    SEXP Rf_mkChar(const char *); 
          ^
    schema.c:122:25: warning: passing 'const char *' to parameter of type 'const xmlChar *' (aka 'const unsigned char *') converts between pointers 
      to integer types with different sign [-Wpointer-sign] 
     p = xmlHashLookup(t, CHAR_DEREF(STRING_ELT(name, 0))); 
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    ./RSCommon.h:140:27: note: expanded from macro 'CHAR_DEREF' 
     #define CHAR_DEREF(x) CHAR((x)) 
           ^~~~~~~~~ 
    /usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include/Rinternals.h:440:18: note: expanded from macro 'CHAR' 
    #define CHAR(x)   R_CHAR(x) 
          ^~~~~~~~~ 
    /Users/richiethomas/anaconda/include/libxml2/libxml/hash.h:171:22: note: passing argument to parameter 'name' here 
              const xmlChar *name); 
                  ^
    2 warnings generated. 
    clang -I/usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include -DNDEBUG -DLIBXML -I/Users/richiethomas/anaconda/include/libxml2 -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DDUMP_WITH_ENCODING=1 -DUSE_XML_VERSION_H=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DNO_XML_HASH_SCANNER_RETURN=1 -DLIBXML_NAMESPACE_HAS_CONTEXT=1 -DHAVE_R_CETYPE_T=1 -DHAVE_XML_WITH_ZLIB=1 -DHAVE_XML_HAS_FEATURE=1 -DUSE_R=1 -D_R_=1 -DHAVE_VALIDITY=1 -DXML_REF_COUNT_NODES=1 -I. -DLIBXML2=1 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -fPIC -g -O2 -c xmlsecurity.c -o xmlsecurity.o 
    clang -I/usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include -DNDEBUG -DLIBXML -I/Users/richiethomas/anaconda/include/libxml2 -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DDUMP_WITH_ENCODING=1 -DUSE_XML_VERSION_H=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DNO_XML_HASH_SCANNER_RETURN=1 -DLIBXML_NAMESPACE_HAS_CONTEXT=1 -DHAVE_R_CETYPE_T=1 -DHAVE_XML_WITH_ZLIB=1 -DHAVE_XML_HAS_FEATURE=1 -DUSE_R=1 -D_R_=1 -DHAVE_VALIDITY=1 -DXML_REF_COUNT_NODES=1 -I. -DLIBXML2=1 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -fPIC -g -O2 -c xpath.c -o xpath.o 
    xpath.c:36:41: warning: passing 'const xmlChar *' (aka 'const unsigned char *') to parameter of type 'const char *' converts between pointers 
      to integer types with different sign [-Wpointer-sign] 
       SET_NAMES(ref, ScalarString(mkCharCE(el->name, encoding))); 
                ^~~~~~~~ 
    /usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include/Rdefines.h:135:54: note: expanded from macro 'SET_NAMES' 
    #define SET_NAMES(x, n)   setAttrib(x, R_NamesSymbol, n) 
                   ^
    /usr/local/Cellar/r/3.2.4_1/R.framework/Resources/include/Rinternals.h:889:30: note: passing argument to parameter here 
    SEXP Rf_mkCharCE(const char *, cetype_t); 
           ^
    1 warning generated. 
    clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.2.4_1/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o XML.so DocParse.o EventParse.o ExpatParse.o HTMLParse.o NodeGC.o RSDTD.o RUtils.o Rcatalog.o Utils.o XMLEventParse.o XMLHashTree.o XMLTree.o fixNS.o libxmlFeatures.o schema.o xmlsecurity.o xpath.o -L/Users/richiethomas/anaconda/lib -lxml2 -lz -liconv -lm -lz -lxml2 -F/usr/local/Cellar/r/3.2.4_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation 
    installing to /usr/local/lib/R/3.2/site-library/XML/libs 
    ** R 
    ** inst 
    ** preparing package for lazy loading 
    Creating a generic function for ‘source’ from package ‘base’ in package ‘XML’ 
    in method for ‘xmlAttrsToDataFrame’ with signature ‘"AsIs"’: no definition for class 「AsIs」 
    in method for ‘readKeyValueDB’ with signature ‘"AsIs"’: no definition for class 「AsIs」 
    in method for ‘readSolrDoc’ with signature ‘"AsIs"’: no definition for class 「AsIs」 
    ** help 
    *** installing help indices 
    ** building package indices 
    ** testing if installed package can be loaded 
    Error : .onLoad failed in loadNamespace() for 'XML', details: 
     call: dyn.load(file, DLLpath = DLLpath, ...) 
     error: unable to load shared object '/usr/local/lib/R/3.2/site-library/XML/libs/XML.so': 
     dlopen(/usr/local/lib/R/3.2/site-library/XML/libs/XML.so, 6): Library not loaded: libxml2.2.dylib 
     Referenced from: /usr/local/lib/R/3.2/site-library/XML/libs/XML.so 
     Reason: image not found 
    Error: loading failed 
    Execution halted 
    ERROR: loading failed 
    * removing ‘/usr/local/lib/R/3.2/site-library/XML’ 

    The downloaded source packages are in 
     ‘/private/var/folders/jy/0cwn40p951xc7f1480z3sxzm0000gn/T/RtmpEi0XEv/downloaded_packages’ 
    Warning message: 
    In install.packages("XML") : 
     installation of package ‘XML’ had non-zero exit status 

回答

1

你解釋什麼是錯的,並沒有什麼幫助。在這裏

XML包文檔:https://cran.r-project.org/web/packages/XML/index.html

收費attetion到它You are trying to use a version 2.* edition of libxml but an incompatible library.

什麼系統都使用你說?我使用OSX,當我有一個類似的問題,我也跑

brew install libxml2 

,然後它的工作

我也看到使用r 3.0+這應該是非常兼容。

+0

,我跑了「釀安裝libxml2的」,但家釀說,這是已安裝。我將編輯該問題以添加此信息。 –

+0

如何「釀造醫生」,修復所有的錯誤和警告,然後「釀造修剪」? – pachamaltese

+0

pachamaltese:試過這個,「brew prune」從/ usr/local刪除了16個符號鏈接和4個目錄,但問題仍然存在。 –

1

我用蟒蛇安裝XML解決了這個問題:我在OSX

conda install -c r r-xml=3.98_1.5 
+0

小心這樣做 - 上面的命令安裝了多種東西,包括'r-base-3.3.2-1' – user25494

+0

+1。它對我很好。我有我的主要R作爲conda R,所以這也解決了更新。 –

+0

無論出於何種原因,這並不適用於我,但如果我解壓版本'conda install -c r r-xml',它對我來說很有用。有關文檔,請參閱https://anaconda.org/r/r-xml。 – Vincent