spacyr installation on R: /usr/local/bin/python is not a python executable - r

I used this instruction to install spacyr on RStudio (mac os)
I have both python 2 and 3 so I run
library(spacyr)
spacy_initialize(python_executable = "/usr/local/bin/python")
It returns an error:
Error in check_spacy_model(python_executable, model) :
/usr/local/bin/python is not a python executable
Any advice on how to fix it? Thanks.

I spent a lot of time figuring out this issue for myself. For me the problem was I had installed spacy using conda rather than pip so it was unable to setup symlink.
uninstall spacyr
uninstall spacy from python(if you have installed using conda)
Install spacy with pip only
Install the latest version of spacyr from github.

Related

not able to install 'fable' package (ERROR: compilation failed for package ‘fable’)

I am trying to install fable running the command install.packages("fable"), as it says in https://cran.r-project.org/web/packages/fable/readme/README.html
however i am getting the following:
It says clearly that it is because i don't have llapack, lblas and lgfortran in my computer. But i am not sure how to procede here. I'm using Ubuntu 20.04.3 LTS
I'll appreciate any guidence.
To install from sources, you will need a GNU Fortran compiler installed. On Ubuntu this can be done with sudo apt install gfortran.
Alternatively, you can install a precompiled binary from the RStudio Package Manager - some guidance on how this can be done can be found here: https://packagemanager.rstudio.com/client/#/repos/1/overview

Installing rsvg library in R 4.0.2 (conda-forge)

I'm facing difficulties downloading the r package rsvg. I created first an environment with conda for the latest R version 4.0.2 following these instructions. I was able to download many other R packages & bioconductor packages without problem, however, this one produces huge pile of lines while configuring it and ends with errors downloadind its dependencies (systemfonts, stringi, stringr, gdtools, magick, svglite, knitr). My exact command is install.packages("rsvg", dependencies =T). Trying to download each of those packages produced also a tree of required dependencies (with configuration fail at the end of each).
Among the lines I noticed this error /user/include/freetype2/freetype/config/ftheader.h:3:12: fatal error x86_64-linux-gnu/freetype2/config/fthreader.h no such file or directory which make me suspect that my R installation is incopmlete or corrupted. I tested it with other R versions (e.g. R 3.6.0) yet the same error appear. Installing it on windows (Rstudio 3.6.2) also didn't work, and now I'm wondering if this package needs to be installed differently or it is system related problem? Any help would be highly appreciated
You need to create a new environment and then you can install R 4.+ in Anaconda. Follow these steps.
conda create --name r4-base
After activating r4-base run these commands
conda install -c conda-forge r-base
conda install -c conda-forge/label/gcc7 r-base
Finally, you will notice r-basa version 4 will be installed.
Thereafter, you can install any supported packages. But with this only, you won't have the ability to use it in the Jupyter notebook. You need to install install.packages('IRkernel') and Jupyter notebook as well if you want to use it. Otherwise you are good to go with R-Studio.
For Jupyter Installation and RKernel.
conda install jupyter
Then open the R console. Write in R console
install.packages('IRkernel')
IRkernel::installspec()
Congrats! You can use Notebook for Python and R.

Can't install tensorflow in R, my machine is 64 bit but R doesn't detect it

I'm using windows, my problem is that while trying to install tensorflow in R the following error message appears.
Error in install_tensorflow(method = method, conda = conda, version = tensorflow, :
Unable to install TensorFlow on this platform.Binary installation is only available for 64-bit platforms.
My machine is 64 bit, so I don't understand where is the problem.
I've already cheked if my anaconda installation and the python version are 64bit and they are.
I can install tensorflow in python without any error, but i can't in R.
I've tried to redirect the R tensorflow installation to the python environment but i don't know if it can really help.
> library(tensorflow)
> install_tensorflow()
Error in install_tensorflow() :
Unable to install TensorFlow on this platform.Binary installation is only available for 64-bit platforms.
Can you try to install older version of tensorflow which is 1.5.0 using command pip install tensorflow==1.5.0

How to install libxml2 package in R if it's not available for my version?

I wanted to install "DESeq2" package in R, but it was missing the xml2-config file. I found somewhere that it can be obtained by installing the libxml2 package, but when I tried it gives error that it's not available for R version 3.4.2. Anyone has idea what to do?
You can install the dev version: devtools::install_github("r-lib/xml2")
After running what #amarchin wrote it didn't work instantly but R suggested to install libxml2-dev. So I run: sudo apt-get install libxml2-dev in Terminal.
And then in R console I typed the code from #amarchin: devtools::install_github("r-lib/xml2")
And it worked :)

How to install Tensorflow for R

I had Tensorflow installed with Anaconda. Now I want use it in R and I need to reinstall Tensorflow, because the note here
NOTE: You should NOT install TensorFlow with Anaconda as there are
issues with the way Anaconda builds the python shared library that
prevent dynamic linking from R.
I already tried to uninstall from Anaconda and install with pip but its came to the same place in anaconda directory. Tesorflow is working from terminal but in R shows Error: Command failed (1)
Anybody can help me to how I can solve the problem? Should I uninstall anaconda and install Tensorflow using pip?
You have several options on what to do. Probably the cleanest one is to install a system-wide python (if not installed yet) and then create a virtual environment. This basically takes your system python binaries and moves them to its own compartment where everythign is isolated from the rest, incl. anaconda. Once you are inside an activated virtual environment you can install all the necessary Python appendages for TensorFlow. Once that is done, make sure you set up a correct environmental PATH for TensorFlow from where R can reach it:
Sys.setenv(TENSORFLOW_PYTHON="/path/to/virtualenv/python/binary")
devtools::install_github("rstudio/tensorflow")
Example of the path to where you installed the virtual environment project would be, I think, something like ~/minion/medvedi/venv_medvedi/bin/python.
This is no longer an issue, the documentation was updated too.
See here:
https://github.com/rstudio/tensorflow/commit/4e1e11d6ba2fe7efe1a03356f96172dbf8db365e
With the help of Keras, we can install the TensorFlow package in R.
install_keras()
library(keras)
devtools::install_github("rstudio/keras")
install_tensorflow(package_url = "https://pypi.python.org/packages/b8/d6/af3d52dd52150ec4a6ceb7788bfeb2f62ecb6aa2d1172211c4db39b349a2/tensorflow-1.3.0rc0-cp27-cp27mu-manylinux1_x86_64.whl#md5=1cf77a2360ae2e38dd3578618eacc03b")
library(tensorflow)
Keras is a high-level neural network API for deep learning from TensorFlow Google.
my suggestion is to install anaconda and create an environment called "r-reticulate".
you can do it using anaconda navigator or
reticulate::conda_create(envname = "r-reticulate")
then to check that env detected by reticulate, use reticulate::conda_python().it must return directory of python.exe for your env.
after that you can install tensorflow by install_tensorflow(). [not working in my case]
so I install the tesnorflow from CMD.
follow these steps:
open the cmd :]
activate the r-reticulate env using conda activate r-reticulate (you may need your directory to conda directory if you did not add conda to your PATH)
use : conda install -c anaconda tensorflow
now in R, you can use TensorFlow.
for installing Keras, you can use pip install Keras. [i tried install_keras() function after the installation of tensorflow, but it ruined my TensorFlow installation also]
Eventually I found the best and fast method to do it in R:
devtools::install_github("rstudio/keras")
library(keras)
install_keras(method = "conda")
install_keras(tensorflow = "gpu")
tensorflow::install_tensorflow()

Resources