Unable to install R package due to XML dependency mismatch

后端 未结 4 2014
旧巷少年郎
旧巷少年郎 2021-01-04 20:55

I launched R in my command-line and typed the following:

install.packages(\"XML\")

After selecting a mirror site, I saw the following outpu

相关标签:
4条回答
  • Solution for Mac OS Catalina (i.e. in zsh).

    I'm a novice, but this worked for me.

    1. 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.)

    2. 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 ~.)

    3. 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.)

    4. 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.

    0 讨论(0)
  • 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).

    0 讨论(0)
  • 2021-01-04 21:20

    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.

    0 讨论(0)
  • 2021-01-04 21:24

    I solved this problem by using anaconda to install XML:

    conda install -c r r-xml=3.98_1.5
    
    0 讨论(0)
提交回复
热议问题