Just a quick aside that I like this question. It's a good question. Some questions are "good" because they are problems that will impact many people, but that's probably not the case here. Some are "good" because they are thought-provoking or hard problems to solve -- Again, not-so-much here. This one is good because it includes what you've done to try to solve the problem (the Search, and research ... rule). Only with this information is the problem apparent!
I also added R to the PATH with the command export PATH=$PATH:/mnt/c/Program\ Files/R/R-4.2.1/bin/x64/R.exe
, as well as setting an R_HOME variable: R_HOME=/mnt/c/Program\ Files/R/R-4.2.1/bin/x64/
So this indicates that you have installed the Windows version of R, but you are trying to install this package in Ubuntu (Linux/WSL) using the Linux pip
command. Unfortunately this just isn't going to work. You'll need to either be using:
- Windows Python with Windows R with Windows pip
- Or the Linux versions of all of the above
The Linux version of pip
just isn't going to look for R.exe
, because the Linux version is just R
. Linux doesn't really have the concept of file extensions.
Even if you were able to tell the pip
installer somehow that it should look for R.exe
, you'd still run into multiple other issues due to:
- Linux paths using the
/
separator vs. Windows paths using \
.
- (Potentially) Linux-native R modules not running inside a Windows-native Python process.
- Differences in expected locations of configuration files.
- And probably a few others
If you want to develop using the Windows version of R, you'll need to install the Windows version of Python/Pip and work from PowerShell or CMD.
However, if you want to develop using the Linux/Ubuntu versions through WSL, then you'll need to use the Linux version of R. This is an area where I don't have a lot of expertise myself, but my understanding is that most people use the CRAN PPA to obtain the latest R version in Ubuntu. See this Ask Ubuntu question (old, but I believe still relevant -- Also points to a Stack Overflow question) or this Digital Ocean guide for details.
Note that, since R is heavily dependent on a GUI, you'll need to either be running WSL under Windows 11 with WSLg support, or use one of the workarounds on Windows 10. See this and this (much more detailed) post for more information.