I launched R in my command-line and typed the following:
install.packages("XML")
After selecting a mirror site, I saw the following output:
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
I Googled around and found this link, which suggested running the 'which xmllint' command in the command line to find any XML installations which might conflict with the one R depends on. The output when I ran it was:
/Users/richiethomas/anaconda/bin/xmllint
Correct me if I'm wrong, but it appears that my Python installation has an XML dependency which conflicts with the one R wants to download. Is this right? And if so, how can I fix it so that both Python and R are installed on my machine?
EDIT: I am using OSX. I ran "brew install libxml2" but Homebrew said it was already installed.
EDIT #2: I tried un-installing and re-installing R via Homebrew, and I am still getting the same error.
EDIT #3: I ran "brew info libxml2" and saw that there is an "--with-python" flag which enables a build with Python support. I also noticed the following:
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
I ran "brew uninstall libxml2" and then "brew install libxml2 --with-python", and then set the above 2 environment variables using the "export" command. Then I re-ran R and again tried to install the XML package. I saw dozens of warnings of the type "passing argument to parameter here" (see below), followed by a non-zero exit code:
* 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
I solved this problem by using anaconda to install XML:
conda install -c r r-xml=3.98_1.5
Solution for Mac OS Catalina (i.e. in zsh).
I'm a novice, but this worked for me.
Make sure you have libxml2 installed in homebrew. (If you got it, brew list | grep libxml2 should confirm it; otherwise install it brew install libxml2. Don't have homebrew? Install it.)
Either create a zsh run com, touch ~/.zshrc, or find it in your home directory cd ~. (Use ls -a in Terminal to see if its in ~.)
Then make sure: export PATH="/usr/local/opt/libxml2/bin:$PATH" is in there (i.e. in ~/.zshrc). It shouldn't be in there yet! Add it using sudo nano ~/.zshrc. Then save it (ctrl + x, Y, enter). This should make sure the path to brew's libxml2 is the first thing that comes up when looking for libxml2. (FYI, I also added it to ~/.zprofile. I don't know which one is correct.)
Ok, now restart your terminal. Then run R in the Terminal using R. Once R has started, install.packages("XML"), pick a server to download it, and you should be good to go.
adding to #Travis's answer using conda install -c r r-xml=3.98_1.5 or conda install -c conda-forge r-xml works.
But make sure to run conda update r-essentials and reopen/restart the r terminal\notebook (whichever is your case).
You explained what is wrong and that helps.
XML package documentation in here: https://cran.r-project.org/web/packages/XML/index.html
Pay attetion to where it says You are trying to use a version 2.* edition of libxml
but an incompatible library.
What system are you using? I use OSX and when I had a similar issue I did run
brew install libxml2
and then it worked
I also see you use R 3.0+ and that should be very compatible.
I am trying to follow an example for Cython builds from here http://blog.perrygeo.net/2008/04/19/a-quick-cython-introduction/, except my c1.pyx is simply helloworld.pyx with "print "Hello World"":
# this will create a c1.c file - the C source code to build a python extension
cython c1.pyx
# Compile the object file
gcc -c -fPIC -I/usr/include/python2.5/ c1.c
# Link it into a shared library
gcc -shared c1.o -o c1.so
The reason I am doing it in the command line is because my setup.py is giving me an error so I am doing it manually to see what is wrong.
The last step (gcc -shared c1.o -o c1.so) is where I hit the following error:
c:/users/MyName/anaconda/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../..
/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
c:/users/MyName/anaconda/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../..
/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\Users\\MyName\\Anaconda\\Scripts\\gcc.bat' failed with exit st
atus 1
Any suggestions?
EDIT1: Thank you #mat for the edit. Also, I was noticing I didn't have Visual C++ 2008 installed on my computer. Not sure if Anaconda requires this for GCC and if this is the solution.
When installing ReportLab 3.1.8, I ran into the problem where I kept getting the error and I could not find where this compiler option was being set.
The point in setup was:
building 'reportlab.lib._rl_accel' extension
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
Here is my solution.
Cause: I keep my mac up to date and as a result it seems I now have a newer (different) version of the c compiler (clang) than the one that allowed the "-mno-fused-madd" command line switch.
Solution: I did not find the above switch in any file in the reportlab source. It had to be on the computer itself. The culprit seemed to be in the distutils, because setup.py uses module distutils.
The problem was in the file /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py. This file contains definitions as a dictionary named build_time_vars. We are obviously in the right place as we have a build time problem.
First make a copy as a safeguard.
sudo <editor> <file path> to edit the file.
Then editing this file, search for and remove the switch -mno-fused-madd from the file. I found it in line beginning with 'CFLAGS' since this is a compile flag.
Change the line:
... -fwrapv -mno-fused-madd -DENABLE_DTRACE ... to ... -fwrapv -DENABLE_DTRACE ...
Save the file and continue with your build. It will now stay fixed. No need for environment variables or any such thing.
Edit: While you are at it, remove both _sysconfigdata.pyc and _sysconfigdata.pyo files.
You can still repress these errors from clang by using the following environment variables:
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
A detailed answer to a similar question can be found here:
clang error: unknown argument: '-mno-fused-madd' (python package installation failure)
According to the following the issue has also been fixed in OS X 10.9.3:
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
I am getting above error when trying to import ssl module.
In fact, the error showed up during the build and _ssl module was added to the failed module list.
However, the compilation and link went well.
There was no error on compilation and link phases, only some warnings. However, during Python build, there is an import phase right after the link, which shows the same error as stated.
building '_ssl' extension
xlc_r -DNDEBUG -O -IInclude -I. -I/usr/local/include -c /aix/Modules/_ssl.c -o build/temp.aix-6.1-3.3/aix/Modules/_ssl.o
"/aix/Modules/_ssl.c", line 262.17: 1506-196 (W) Initialization between types "void*" and "struct _object*(*)(struct {...}*)" is not allowed.
/aix/Modules/ld_so_aix xlc_r -bI:/aix/Modules/python.exp build/temp.aix-6.1-3.3/aix/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.aix-6.1-3.3/_ssl.so
ld: 0711-224 WARNING: Duplicate symbol: .bcopy
ld: 0711-224 WARNING: Duplicate symbol: .memcpy
ld: 0711-224 WARNING: Duplicate symbol: .memmove
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
*** WARNING: importing extension "_ssl" failed with build/lib.aix-6.1-3.3/_ssl.so: <class 'RuntimeError'>: invalid slot offset: <traceback object at 0x3017e9e0>
Could anyone shed some lights on how to get it work?
Env:
Python: 3.3.2
OpenSSL: 0.9.8y (also tried 0.9.7)
OS: AIX 6.1 (also tried on HPUX_1131_IA)
Thanks in advance!
For future reference:
This is solved, there are different versions of SSL, and the error happened when the wrong one was chosen and the setup.py was messed up.
This problem has been mentioned elsewhere, but it does not provide a working solution, so I would still like to keep a ticket open.
c:\Users\me\Desktop\temp\py-bcrypt-0.2>setup.py install build --compiler=min
gw32
running install
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c bcrypt/bcrypt_python.c -o build\temp.win32-2.7\Release\bcrypt\bcrypt_python.o
bcrypt/bcrypt_python.c:29:26: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c:29:38: error: expected declaration specifiers or '...' before 'u_int16_t'
bcrypt/bcrypt_python.c:29:49: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt':
bcrypt/bcrypt_python.c:56:2: error: too many arguments to function 'encode_salt'
bcrypt/bcrypt_python.c:29:6: note: declared here
error: command 'gcc' failed with exit status 1
This is after getting rid of the initial “error: Setup script exited with error: Unable to find vcvarsall.bat”, I am left with what seems like a Gordic knot. pip and easy-install do not work. I have also read a number of other articles.
I don’t need to implement bcrypt at the moment, so it is not an urgent matter, but obviously, implementing a secure password protection is vital.
The simplest way I found was to download and install windows binaries, rather than trying to compile myself. This guy has some on bitbucket
supposing you are using mingw64, you should change _MSC_VER in _WIN32 on ifdefs into bcrypt.c, bcrypt_python.c and pybc_blf.h
(I've also replied the other question)