Hey everyone and happy new year! I recently bought the M1 MacBook Pro (2020) and I am trying to set it up for some bioinformatics work.
While trying to run a function from CellChat package in R that uses Python's umap-learn package, I get the error:
Error in runUMAP(Similarity, min_dist = min_dist, n_neighbors = n_neighbors, :
Cannot find UMAP, please install through pip (e.g. pip install umap-learn or reticulate::py_install(packages = 'umap-learn'))
the thing is I have installed umap-learn already. I got digging and saw that there may be some trouble with reticulate and arm architecture. Things I checked from other errors: When I run reticulate::py_available() I get False. I haven't had any luck getting TRUE unless I initialize it with py_available(initialize=TRUE) I have tried installing python using Brew, Using anaconda (for x86_64), using miniconda3 (for arm), using miniforge3 (for arm) and by installing pyenv and virtualenv (using brew) and setting up a virtual environment just for R.
In all cases I have added the python bin directory so that it is first in R studio's path (by creating a .Renviron file), I have tried specifying RETICULATE_PYTHON variable and by setting python executable from R Studio's global tools. I have also tried creating a conda environment with anaconda that has python and all packages I need (scipy & umap-learn) installed, I set the environment as I mentioned above in my Path etc. but py_available still returns false. Even when I set the variables use_python and use_condaenv.
In the anaconda case, when running py_install(packages= "umap-learn") I see output of conda trying to install the package and it says that package is already installed. But still the umap error appears.
reticulate::py_available()
[1] FALSE
> Sys.which("python")
python
"/Users/gsentis/opt/anaconda3/envs/rpython/bin/python"
> py_install(packages = "umap-learn")
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
# All requested packages already installed.
When executing py_config() I get the following output:
> py_config()
Error in py_initialize(config$python, config$libpython, config$pythonhome, :
/Users/gsentis/opt/anaconda3/envs/rpython/lib/libpython3.9.dylib - dlopen(/Users/gsentis/opt/anaconda3/envs/rpython/lib/libpython3.9.dylib, 0x000A): tried: '/Users/gsentis/opt/anaconda3/envs/rpython/lib/libpython3.9.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpython3.9.dylib' (no such file)
In addition: Warning message:
In file.symlink(target, symlink) :
cannot symlink '/Users/gsentis/opt/anaconda3/envs/rpython/lib' to '/var/folders/xg/ql183z152c757w941k5d23gw0000gn/T/rstudio-fallback-library-path-FyPbMB', reason 'File exists'
Anyone has any suggestion? I upgraded from my mbp-2011 so that I could stop any incompatibilities with newer R versions and now I cannot even do the stuff I did before.
P.S. I tried both R for arm architecture and R for x86_64 and all the stuff I mentioned before still happen. Also, I was on MacOS Big Sur and now I upgraded to MacOS Monterey in case that solved the issue, but no luck.
Thank you very much to everyone who devotes their time to this!
I wish you all a happy new year full of health and errorless executions!
~GeoSen