Git Product home page Git Product logo

Comments (5)

jjallaire avatar jjallaire commented on August 22, 2024

I think the problem is that rpy2 wants to initialize it's own instance of the R runtime, and when it's called via reticulate the R runtime is of course already initialized. Unfortunately I don't think we can find a way around this one.

from reticulate.

jburos avatar jburos commented on August 22, 2024

This sounds reasonable - though it's strange to me that the error is not always triggered by rpy2.

For example, I don't have any problems sourcing numpy, matplotlib or pandas in the following environment :

conda create -n testenv3 python=3 scipy numpy pandas matplotlib
source activate testenv3
pip install rpy2
Rscript run_validate_setup2.R

yields output:

(testenv3) jacquelineburos@jacki1:~/projects/test-reticulate$ Rscript run_validate_setup2.R
python:         /home/jacquelineburos/miniconda3/envs/testenv3/bin/python
libpython:      /home/jacquelineburos/miniconda3/envs/testenv3/lib/libpython3.6m.so
pythonhome:     /home/jacquelineburos/miniconda3/envs/testenv3:/home/jacquelineburos/miniconda3/envs/testenv3
version:        3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
numpy:          /home/jacquelineburos/miniconda3/envs/testenv3/lib/python3.6/site-packages/numpy
numpy_version:  1.12.1

python versions found:
 /home/jacquelineburos/miniconda3/envs/testenv3/bin/python
 /usr/bin/python
 /usr/bin/python3
[1] "checking that numpy is available"
[1] "checking that matplotlib is available"
[1] "checking that rpy2 is available"
[1] "checking that python is initialized"
[1] "loading numpy"
[1] "loading matplotlib"
[1] "loading rpy2"
[1] "setup OK"
[1] "Finished"

Where run_validate_setup2.R looks like the following:

#!/usr/bin/env Rscript

# execute script
source('validate_setup.function.R')
validate_setup(verbose = TRUE, test_packages = c('numpy', 'matplotlib', 'rpy2'))

print('Finished')

If it's OK with you, I'm going to keep working through dependencies of cohorts to try to isolate the issue. My thinking is, in the long run, this might help make reticulate more reliable overall.

from reticulate.

jjallaire avatar jjallaire commented on August 22, 2024

from reticulate.

jburos avatar jburos commented on August 22, 2024

Nope you were right! the error occurs on installing PyVCF, one of the dependencies of cohorts, since that package uses rpy2 to initializes R in the code, but only if rpy2 is installed.

e.g. here:

try:
    from rpy2 import robjects
except:
    robjects = None

In general it seems safer to not have rpy2 installed, since otherwise would be hard to know which packages use it or depend on it. But simply installing it doesn't cause a problem unless one of the python packages uses it.

Anyways I feel better (at least) having tracked this down. Agreed with your earlier statement above that it's unlikely that anything can be done to avoid the issue. Circular r->py->r dependencies seem like a bad idea, in general.

from reticulate.

jjallaire avatar jjallaire commented on August 22, 2024

from reticulate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.