%R works on ipython2.1, but %%R put results on the DOS window instead

Issue #212 new
Big Stone created an issue

Hello,

Sorry if the issue is already open. I get a bad output redirection when I do this :

%load_ext rpy2.ipython

this is going ok

%R X=c(1,4,5,7); sd(X); mean(X)

this will generate the correct output, but on the Kernel DOS window instead of the browser

%%R
Y = c(2,4,3,9)
summary(lm(Y~X))

https://github.com/ipython/ipython/issues/6129

Comments (13)

  1. Laurent Gautier

    Display going to the console on Windows is probably because the Python R console callbacks are broken on windows.

    Check #225. It might solve the observable part of the issue.

  2. Big Stone reporter

    Thanks

    I have difficulties to install rpy2 from source. I'll wait the next release to appear on Christoph Gohlke site

  3. Big Stone reporter

    Ok, I'm a little clever today and I did python setup install on my python 3.4 64 bit.

    There is apparently a small issue at the very end of the install , related to python 3 ?
    ==> I guess this may be the same issue as #224 (I may try to fix one)

    rp = os.popen('"'+r_exec+'" --version')
    rversion = rp.readline()

    File "D:\result_tests\WinPython-64bit-3.4.1.2_build19\python-3.4.1.amd64\lib\distutils\cmd.py", line 107, in ensure_finalized

    self.finalize_options()
    

    File "setup.py", line 117, in finalize_options

    rversion = get_rversion(r_home)
    

    File "setup.py", line 168, in get_rversion

    if rversion.startswith("WARNING"):
    

    TypeError: startswith first arg must be bytes or a tuple of bytes, not str

  4. Big Stone reporter

    Doing a "e" instead of print(e) makes things better under Ipython (with brand new 2.3.4):

    import numpy as np
    import pylab
    X = np.array([0,1,2,3,4])
    Y = np.array([3,5,4,6,7])
    %Rpush X Y
    %R lm(Y~X)$coef
    %R d=resid(lm(Y~X)); e=coef(lm(Y~X))
    %R -o d -o e
    %Rpull e
    #print (e)
    e
    
    <FloatVector - Python:0x000000000A01C5C8 / R:0x000000000B497E20>
    [3.200000, 0.900000]
    
  5. Big Stone reporter

    in setup.py , for Python3 users, you may need to convert cp1252 output to an unicode string first

            rp = os.popen('"'+r_exec+'" --version')
        if sys.version_info[0] == 3 and os.name == "nt":
            rversion = rp.readline().decode(sys.getdefaultencoding())
        else:
            rversion = rp.readline()
        #Twist if 'R RHOME' spits out a warning
    
  6. Big Stone reporter

    python setup.py install still fails (partialy) after, because I don't have r.h, a "sh" shell,
    ... don't kow what is to do from here.

    writing dependency_links to rpy2.egg-info\dependency_links.txt
    writing rpy2.egg-info\PKG-INFO
    writing top-level names to rpy2.egg-info\top_level.txt
    "D:\result_tests\WinPython-64bit-3.4.1.2_build19\tools\R\bin\x64\R" CMD config -
    -ldflags
    'sh' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    "D:\result_tests\WinPython-64bit-3.4.1.2_build19\tools\R\bin\x64\R" CMD config -
    -cppflags
    'sh' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    "D:\result_tests\WinPython-64bit-3.4.1.2_build19\tools\R\bin\x64\R" CMD config L
    APACK_LIBS
    'sh' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    "D:\result_tests\WinPython-64bit-3.4.1.2_build19\tools\R\bin\x64\R" CMD config B
    LAS_LIBS
    'sh' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    Configuration for R as a library:
      include_dirs: ()
      libraries: ()
      library_dirs: ()
      extra_link_args: ()
     # OSX-specific (included in extra_link_args)
      framework_dirs: ()
      frameworks: ()
    reading manifest file 'rpy2.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*patch*' found anywhere in distr
    ibution
    warning: no previously-included files matching '*diff*' found anywhere in distri
    bution
    warning: no previously-included files matching '.hg' found anywhere in distribut
    ion
    warning: no files found matching 'MANIFEST'
    warning: no files found matching 'MPL_LICENSE'
    warning: no files found matching 'GPL_LICENSE'
    warning: no files found matching 'LGPL_LICENSE'
    no previously-included directories found matching 'dist'
    warning: no files found matching 'doc\source\rpy2_logo.png'
    writing manifest file 'rpy2.egg-info\SOURCES.txt'
    installing library code to build\bdist.win-amd64\egg
    running install_lib
    running build_py
    running build_ext
    building 'rpy2.rinterface._rinterface' extension
    D:\result_tests\WinPython-64bit-3.4.1.2_build19\scripts\..\python-3.4.1.amd64\..
    \tools\mingw32\bin\gcc.exe -mdll -O -DMS_WIN64 -Wall -DWin32=1 -DWin64=1 -DMS_WI
    N64=1 -I.\rpy\rinterface -ID:\result_tests\WinPython-64bit-3.4.1.2_build19\pytho
    n-3.4.1.amd64\include -ID:\result_tests\WinPython-64bit-3.4.1.2_build19\python-3
    .4.1.amd64\include -c .\rpy\rinterface\_rinterface.c -o build\temp.win-amd64-3.4
    \Release\.\rpy\rinterface\_rinterface.o -m64
    In file included from .\rpy\rinterface\_rinterface.c:58:0:
    .\rpy\rinterface\_rinterface.h:8:15: fatal error: R.h: No such file or directory
    
     #include <R.h>
                   ^
    compilation terminated.
    error: command 'D:\\result_tests\\WinPython-64bit-3.4.1.2_build19\\scripts\\..\\
    python-3.4.1.amd64\\..\\tools\\mingw32\\bin\\gcc.exe' failed with exit status 1
    
    C:\Users\famille\Downloads\bitbucket\rpy2-2.4.4.tar\dist\rpy2-2.4.4\rpy2-2.4.4>
    
  7. Big Stone reporter

    oups, said nothing, used the decrepited version "%load_ext rmagic" instead of "%load_ext rpy2.ipython "

  8. Log in to comment