I am trying to intsall the r interface to keras/tensoflow in R studio following the code bellow:
`install.packages('devtools')
devtools::install_github("rstudio/keras")
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(version = "2.8.0")
library(keras)
install_keras()
reticulate::use_condaenv("anaconda3", required = TRUE)`
All things are Ok until install_tensorflow(version = "2.8.0"), the r studio says
No non-system installation of Python could be found. Would you like to download and install Miniconda?
I choose because I want to use the python of my our anaconda environment. But when finishing this command line, it has a warning message
Warning message:
In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),:
running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat"
run --prefix "C:\Users\jinhu\anaconda3" --no-capture-output "python" -c "import os;
print(os.environ['PATH'])"' had status 1
In addition, when I input the py_config function to see the available python version, it output:
Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args), : running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1
below is my conda list:
conda_list()
name python
base C:\\Users\\jinhu\\anaconda3/python.exe
pytorch C:\\Users\\jinhu\\anaconda3\\envs\\pytorch/python.exe
r-reticulate C:\\Users\\jinhu\\anaconda3\\envs\\r-reticulate/python.exe
tensorflow C:\\Users\\jinhu\\anaconda3\\envs\\tensorflow/python.exe
Here is my conda verson:
(base) C:\Users\jinhu>conda info
active environment : base
active env location : C:\Users\jinhu\anaconda3
shell level : 1
user config file : C:\Users\jinhu\.condarc
populated config files : C:\Users\jinhu\.condarc
conda version : 4.10.3
conda-build version : 3.21.6
python version : 3.9.7.final.0
virtual packages : __cuda=11.4=0
__win=0=0
__archspec=1=x86_64
base environment : C:\Users\jinhu\anaconda3 (writable)
conda av data dir : C:\Users\jinhu\anaconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\jinhu\anaconda3\pkgs
C:\Users\jinhu\.conda\pkgs
C:\Users\jinhu\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\jinhu\anaconda3\envs
C:\Users\jinhu\.conda\envs
C:\Users\jinhu\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.7 Windows/10 Windows/10.0.22000
administrator : False
netrc file : None
offline mode : False
Also when I try use_condaenv( "r-reticulate"), it shows:
`Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args), : running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1`
I think the question is new-created r-reticulate environment cannot find the available python, what should I do to solve it?
Related
I tried to install R on cluster server using conda. Conda created environment successfully, but it can not install R. It gives the following error message:
-bash-4.2$ conda install -c conda-forge r-base=4.2.0
Collecting package metadata (current_repodata.json): failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/opt/ohpc/pub/anaconda3/lib/python3.8/site-packages/conda/gateways/connection/session.py", line 52, in __call__
return cls._thread_local.session
AttributeError: '_thread._local' object has no attribute 'session'
active environment : /home/zwei/bartsfm
active env location : /home/zwei/bartsfm
shell level : 3
user config file : /home/zwei/.condarc
populated config files : /home/zwei/.condarc
conda version : 4.8.3
conda-build version : 3.18.11
python version : 3.8.3.final.0
virtual packages : __glibc=2.17
base environment : /opt/ohpc/pub/anaconda3 (read only)
channel URLs : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/zwei/conda/pkgs
envs directories : /home/zwei/bartsfm
/home/zwei/.conda/envs
/opt/ohpc/pub/anaconda3/envs
platform : linux-64
user-agent : conda/4.8.3 requests/2.24.0 CPython/3.8.3 Linux/3.10.0-1160.76.1.el7.x86_64 Linux/unknown glibc/2.17
UID:GID : 1620:1546
netrc file : None
offline mode : False
...
An unexpected error has occurred. Conda has prepared the above report.
Upload successful.
I guess I mess up the environment variables for conda. Could any one help? Many thanks.
After updating R to 4.0.3 and RStudio to the newest version, I have issues with the cointegration of RStudio and RTools described in these questions (before R was 3.6 and RTools 35 and everything worked fine):
https://community.rstudio.com/t/problems-with-r-4-0-0-windows-error-package-or-namespace-load-failed-for-stats-in-indl-x-as-logical-local-as-logical-now/62958/6
https://community.rstudio.com/t/rtools-not-found-after-r-4-0-0-installation/63356/3
I found that I should set some environmental variables for my user. However, I do not understand how to do it, despite the fact that the new path to RTolls should have path C:\rtools40\usr\bin (with older Rtools version it is C:\RTools\bin. Could you help with that?
Additionally,I did these steps, but then got error when downloading package
> Sys.setenv(PATH = paste("C:/rtools40/usr/bin", Sys.getenv("PATH"), sep=";"))
> install_github("brettjbush/R-Websockets")
Downloading GitHub repo brettjbush/R-Websockets#HEAD
√ checking for file 'C:\Users\NAME\AppData\Local\Temp\RtmpSMB4KM\remotes2bcc582622c6\brettjbush-R-Websockets-fc7ee9c/DESCRIPTION' (598ms)
- preparing 'websockets':
√ checking DESCRIPTION meta-information ...
- cleaning src
Warning in system2(command, args, stdout = NULL, stderr = NULL, ...) :
'CreateProcess' failed to run 'C:\rtools40\usr\bin\make.exe -f "C:/PROGRA~1/R/R-40~1.3/share/make/clean.mk" -f Makevars.win clean'
Then I tried following and got different error
> Sys.setenv(PATH = paste("C:/rtools40/usr/bin", Sys.getenv("PATH"), sep=";"))
> Sys.setenv(BINPREF = "C:/rtools40/mingw_$(WIN)/bin/")
> install_github("brettjbush/R-Websockets")
Downloading GitHub repo brettjbush/R-Websockets#HEAD
brettjbush-R-Websockets-fc7ee9c/man/websocket_close.Rd: truncated gzip input
tar.exe: Error exit delayed from previous errors.
Error: Failed to install 'websockets' from GitHub:
Does not appear to be an R package (no DESCRIPTION)
In addition: Warning messages:
1: In utils::untar(tarfile, ...) :
‘tar.exe -xf "C:\Users\NAME\AppData\Local\Temp\RtmpSMB4KM\file2bccd21558.tar.gz" -C "C:/Users/NAME/AppData/Local/Temp/RtmpSMB4KM/remotes2bcc2b6a75d4"’ returned error code 1
2: In system(cmd, intern = TRUE) :
running command 'tar.exe -tf "C:\Users\NAME\AppData\Local\Temp\RtmpSMB4KM\file2bccd21558.tar.gz"' had status 1
I have installed R from the official site and want to use it from jupyter notebook and jupyterlab. For that i have installed IRkernal in R using:
install.packages('IRkernel')
and then when I type IRkernel::installspec(user = FALSE) to make this installation visible globally,
I get following error:
Error in IRkernel::installspec(user = FALSE) :
jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127.
In addition: Warning message:
In system2("jupyter", c("kernelspec", "--version"), FALSE, FALSE) :
'"jupyter"' not found
I have jupyter installation on miniconda and I don't want to use the conda distribution of R. What should I do?
The command to setup IRkernel has to be run in the same environment as the jupyter installation. Due to this, It won't work with R.exe directly. For this, you have to run the command IRkernel::installspec(user=FALSE) in the Anaconda prompt.
I try to run locally this repository
I installed git but when I run this command:
sh requirements.sh
I receive this error:
$ sh requirements.sh
Java is installed
which: no C:Program in (/c/Users/Username/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Username/bin:/c/Perl64/site/bin:/c/Perl64/bin:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program
Files/Java/jre1.8.0_151/bin:/c/Program
Files/Java/jre1.8.0_151:/c/WINDOWS/System32/OpenSSH:/c/Program Files
(x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program
Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program
Files/Intel/WiFi/bin:/c/Program Files/Common
Files/Intel/WirelessCommon:/c/Program Files/Git
LFS:/cmd:/mingw64/bin:/usr/bin:/c/Program Files/R/R-3.5.2:/c/Program
Files/R/R-3.5.2/bin:/c/Program
Files/R/R-3.5.2/bin/Rscript.exe:/c/Users/Username/AppData/Local/Microsoft/WindowsApps:/c/Program
Files/Docker Toolbox:/usr/bin/vendor_perl:/usr/bin/core_perl)
which: no FilesRR-3.5.2binR in (/c/Users/Username/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Username/bin:/c/Perl64/site/bin:/c/Perl64/bin:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program
Files/Java/jre1.8.0_151/bin:/c/Program
Files/Java/jre1.8.0_151:/c/WINDOWS/System32/OpenSSH:/c/Program Files
(x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program
Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program
Files/Intel/WiFi/bin:/c/Program Files/Common
Files/Intel/WirelessCommon:/c/Program Files/Git
LFS:/cmd:/mingw64/bin:/usr/bin:/c/Program Files/R/R-3.5.2:/c/Program
Files/R/R-3.5.2/bin:/c/Program
Files/R/R-3.5.2/bin/Rscript.exe:/c/Users/Username/AppData/Local/Microsoft/WindowsApps:/c/Program
Files/Docker Toolbox:/usr/bin/vendor_perl:/usr/bin/core_perl)
R is installed
Warning in install.packages(c("caret"), dependencies = c("Imports", "Depends"), :
'lib = "C:/Program Files/R/R-3.5.2/library"' is not writable
Error in install.packages(c("caret"), dependencies = c("Imports", "Depends"), :
unable to install packages
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called 'caret'
Execution halted
Please is there any idea what should I fix in the paths?
Edit
Running another command I receive this error:
MINGW64 /c/git/Senti4SD/ClassificationTask (master)
$ Rscript requirements.R
Warning in install.packages(c("caret"), dependencies = c("Imports", "Depends"), :
'lib = "C:/Program Files/R/R-3.5.2/library"' is not writable
Error in install.packages(c("caret"), dependencies = c("Imports", "Depends"), :
unable to install packages
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called 'caret'
Execution halted
It seems the command line couldn't find the "which" command, which is supplied with mingw.
If you installed Git for Windows, you should try looking for a installed program called "Git bash" and run your script from there.
You should be able to right click the folder and select "open git bash here", if you installed the Explorer extension.
Edit:
Its a problem related to install permission. Try running "Git bash" with Administrative privileges in Windows.
If the bash dont work, run "Rscript requirements.R" directly.
I have an issue compiling the RInside examples on Windows.
In Rstudio, running
sourceCpp("C:/Users/Admin/Documents/R/win-library/3.5/RInside/examples/standard/rinside_sample0.cpp")
gives
fatal error: RInside.h: No such file or directory
From the command promt, running
cd C:\Users\Admin\Documents\R\win-library\3.5\RInside\examples\standard
make -f Makefile.win rinside_sample0
gives
Error in loadNamespace(name) : aucun package nommé 'Rcpp' n'est trouvé
Error in loadNamespace(name) : aucun package nommé 'RInside' n'est trouvé
Apparently these packages are not found, so I tried the following:
Ran this from the command line set R_HOME=C:\Program Files\R\R-3.5.2
Checked that Rtools and R dirs are present in the path
Modified the Makefile.win like so:
R_LIBS_USER := "C:/Users/Admin/Documents/R/win-library/3.5"
R_ARCH := --arch x64
But still getting the same errors. Any help? Thanks
EDIT: this answer might provide a solution by including this line of code somewhere
export R_LIBS_SITE=c:/R/site-library
However I don't know where to include it.
EDIT2 I have tried to reinstall Rcpp and RInside in both library locations (by running RStudio as admin)
remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")
In RStudio I still have the same error using sourceCpp, however, using the comand prompt and make approach I do get a different error:
make -f Makefile.win rinside_sample0
g++.exe: error: Files/R/R-3.5.2/library/RInside/include: No such file or directory
I suppose the space in the path is the problem " Files..." will try to reinstall R in a non-spaced path
Reinstalling R in a path without spaces, installing the latest packages, and setting R_HOME environment variable to the new installation folder C:\R\R-3.5.2 solved the problem.
remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")