KrishnaswamyLab / MAGIC

MAGIC (Markov Affinity-based Graph Imputation of Cells), is a method for imputing missing values restoring structure of large biological datasets.
GNU General Public License v2.0
341 stars 97 forks source link

Error when loading Rmagic into RStudio #161

Closed nickcicero18 closed 5 years ago

nickcicero18 commented 5 years ago

I installed magic with pip install and then installed it with install.packages('Rmagic') in R and they both worked. But after I do library(Rmagic) I get this error:

Could not find platform independent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001153055c0 (most recent call first): Error: package or namespace load failed for ‘Rmagic’: .onLoad failed in loadNamespace() for 'Rmagic', details: call: mapply(function(from, to) paste(lines[from:to], collapse = "\n"), error: zero-length inputs cannot be mixed with those of non-zero length

My google search suggested that R was using the wrong python version but when I check what version R is using it seems to be the most up to date one

scottgigante commented 5 years ago

Hi @nickcicero18 , are you able to load the reticulate package?

library(reticulate)
py_discover_config(required_module = "magic")

If that works, please post the results here. If not, you might have more luck posting your question at https://github.com/rstudio/reticulate

nickcicero18 commented 5 years ago

It seemed to work:

library(reticulate) Warning message: package ‘reticulate’ was built under R version 3.5.2 py_discover_config(required_module = "magic") python: /usr/local/bin/python3 libpython: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib pythonhome: /Library/Frameworks/Python.framework/Versions/3.7:/Library/Frameworks/Python.framework/Versions/3.7 version: 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52) [Clang 6.0 (clang-600.0.57)] numpy: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy numpy_version: 1.16.4 magic: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/magic

python versions found: /usr/bin/python /usr/local/bin/python3 /Users/nickcicero/anaconda/bin/python /anaconda3/envs/HD4630/bin/python /anaconda3/envs/HD4630.2/bin/python /anaconda3/envs/py2.7/bin/python /anaconda3/envs/py2.7again/bin/python /anaconda3/envs/py2.8/bin/python /anaconda3/envs/Renv/bin/python

scottgigante commented 5 years ago

@nickcicero18 some more reading indicates this is just a broken Python install. An expert might be able to fix it but I would recommend just hiding from it : set your RETICULATE_PYTHON environment variable (probably through .Renviron) to /Users/nickcicero/anaconda/bin/python and R should ignore the broken python3 install