1

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

Frant
  • 5,382
  • 1
  • 16
  • 22
geosen
  • 53
  • 5
  • I came across a ticket on Github for this problem. It had to do with the version of R you have. For Mac, there are versions x86-64 and arm64. Make sure you have the arm64 version. You can use `R.version()` to check. You should see `arch = "aarch64` if you have the right version. ([See the Github ticket on this here](https://github.com/rstudio/reticulate/issues/995).) – Kat Jan 10 '22 at 23:04
  • Thank you for your suggestion! As I mentioned, I tried everything I reported using both versions of R (Uninstalled the first and installed the second and vice versa) and still nothing. Currently, I'm on R arm architecture and anaconda x86_64. I'll try uninstalling anaconda and installing miniforge3(arm architecture) again in case this works. – geosen Jan 11 '22 at 12:33

0 Answers0