2

As have been described previously, when running a cell with

%%R

I receive the following error:

ERROR:root:Cell magic `%%R` not found.

Trying

%load_ext rmagic

leads to:

C:\Anaconda2\envs\ipykernel_py2\lib\site-packages\IPython\extensions\rmagic.py:11:
UserWarning: The rmagic extension in IPython has moved to `rpy2.ipython`,
please see `rpy2` documentation.

warnings.warn("The rmagic extension in IPython has moved to "

Apparently, the command seems "deprecated". I then try:

%load_ext rpy2.ipython

This results in multiple errors, whereupon I check the folder C:\Anaconda2\envs\ipykernel_py2\lib\site-packages\IPython\extensions and find rmagic .py and .pyc, but no files related to rpy2.ipython:

I then try %load_ext rmagic again:

The rmagic extension is already loaded. To reload it, use:
    %reload_ext rmagic.py

The error for %%R does not change.


Finally, I

pip install rpy2

upon which I receive an error when the installer runs Rterm.exe that

libgcc_s_dw2-1.dll (mentioned twice)
libbz2-1.dll
liblzma-5.dll

are missing on this computer and that I have to reinstall RTerm, which I guess is part of RTools. Eventually the stderr/stdout:

Collecting rpy2
 Using cached rpy2-2.8.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\user\appdata\local\temp\pip-build-1mtkwa\rpy2\setup.py",
line 331, in <module>
    ri_ext = getRinterface_ext()
  File "c:\users\user\appdata\local\temp\pip-build-1mtkwa\rpy2\setup.py", line 234,
in getRinterface_ext
    if rexec.version[0] == 'development' or \
  File "c:\users\user\appdata\local\temp\pip-build-1mtkwa\rpy2\setup.py",
line 160, in version
    universal_newlines = True)
  File "C:\Anaconda2\envs\ipykernel_py2\lib\subprocess.py",
line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError:
Command '('C:\\Anaconda2\\R\\bin\\R', '--version')'
returned non-zero exit status -1073741515

R, RStudio, and R-Essentials (via conda) are installed on my computer. During the conda installation there is only a complaint about the p11-kit (PKCS 11), which I assume is unrelated.

Running >jupyter troubleshoot reveals that r-base has version number 0 (scroll down).

[31mDEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.[0m
$PATH:

    C
    \Anaconda2\Library\bin;C
    \Anaconda2\Scripts;C
    \Anaconda2\Library\bin;C
    \Windows\system32;C
    \Windows;C
    \Windows\System32\Wbem;C
    \Windows\System32\WindowsPowerShell\v1.0\;%JAVA%;%PYTHONPATH%;%PYTHONPATH%\Scripts;%PYTHONPATH%\Library\bin;%GITPATH%;C
    \Program Files\MATLAB\R2016b\runtime\win64;C
    \Program Files\MATLAB\R2016b\bin;C
    \Users\user\AppData\Local\Microsoft\WindowsApps;C
    \ProgramData\Oracle\Java\javapath;C
    \Program Files\Git;%GITPATH\cmd%;C
    \Program Files\Git\bin;C
    \Anaconda2;C
    \Anaconda2\Scripts;C
    \Anaconda2\Library\bin;C
    \ProgramData\che;C
    \Program Files\R\R-3.3.2\bin;

As you can see, the PYTHONPATH is defined. This is against the recommendations of Continuum, but I do not see that this could be a culprit.

sys.path:

    C:\Anaconda2\Scripts
    C:\Anaconda2
    C:\Anaconda2\python27.zip
    C:\Anaconda2\DLLs
    C:\Anaconda2\lib
    C:\Anaconda2\lib\plat-win
    C:\Anaconda2\lib\lib-tk
    C:\Anaconda2\lib\site-packages
    C:\Anaconda2\lib\site-packages\Sphinx-1.4.6-py2.7.egg
    C:\Anaconda2\lib\site-packages\win32
    C:\Anaconda2\lib\site-packages\win32\lib
    C:\Anaconda2\lib\site-packages\Pythonwin
    C:\Anaconda2\lib\site-packages\setuptools-27.2.0-py2.7.egg

sys.executable:
        C:\Anaconda2\python.exe

sys.version:
        2.7.12 |Anaconda 4.2.0 (32-bit)| (default, Jun 29 2016, 11:42:13) [MSC v.1500 32 bit (Intel)]

platform.platform():
        Windows-10-10.0.14393

where jupyter:
        C:\Anaconda2\Scripts\jupyter.exe

pip list:
        alabaster (0.7.9)
        anaconda-clean (1.0)
        anaconda-client (1.5.1)
        anaconda-navigator (1.3.1)
        argcomplete (1.0.0)
        astroid (1.4.7)
        astropy (1.2.1)
        Babel (2.3.4)
        backports-abc (0.4)
        backports.shutil-get-terminal-size (1.0.0)
        backports.ssl-match-hostname (3.4.0.2)
        beautifulsoup4 (4.5.1)
        bitarray (0.8.1)
        blaze (0.10.1)
        bokeh (0.12.2)
        boto (2.42.0)
        Bottleneck (1.1.0)
        cdecimal (2.3)
        cffi (1.7.0)
        chest (0.2.3)
        click (6.6)
        cloudpickle (0.2.1)
        clyent (1.2.2)
        colorama (0.3.7)
        comtypes (1.1.2)
        conda (4.2.13)
        conda-build (2.0.2)
        configobj (5.0.6)
        configparser (3.5.0)
        contextlib2 (0.5.3)
        cryptography (1.5)
        cycler (0.10.0)
        Cython (0.24.1)
        cytoolz (0.8.0)
        dask (0.11.0)
        datashape (0.5.2)
        decorator (4.0.10)
        dill (0.2.5)
        docutils (0.12)
        enum34 (1.1.6)
        et-xmlfile (1.0.1)
        ez-setup (0.9)
        fastcache (1.0.2)
        filelock (2.0.6)
        Flask (0.11.1)
        Flask-Cors (2.1.2)
        funcsigs (1.0.2)
        functools32 (3.2.3.post2)
        futures (3.0.5)
        gevent (1.1.2)
        greenlet (0.4.10)
        grin (1.2.1)
        h5py (2.6.0)
        HeapDict (1.0.0)
        idna (2.1)
        imagesize (0.7.1)
        ipaddress (1.0.16)
        ipykernel (4.5.0)
        ipython (5.1.0)
        ipython-genutils (0.1.0)
        ipywidgets (5.2.2)
        itsdangerous (0.24)
        jdcal (1.2)
        jedi (0.9.0)
        Jinja2 (2.8)
        jsonschema (2.5.1)
        jupyter (1.0.0)
        jupyter-client (4.4.0)
        jupyter-console (5.0.0)
        jupyter-core (4.2.0)
        lazy-object-proxy (1.2.1)
        llvmlite (0.13.0)
        locket (0.2.0)
        lxml (3.6.4)
        MarkupSafe (0.23)
        matplotlib (1.5.3)
        menuinst (1.4.1)
        mistune (0.7.3)
        mpmath (0.19)
        multipledispatch (0.4.8)
        nb-anacondacloud (1.2.0)
        nb-conda (2.0.0)
        nb-conda-kernels (2.0.0)
        nbconvert (4.2.0)
        nbformat (4.1.0)
        nbpresent (3.0.2)
        networkx (1.11)
        nltk (3.2.1)
        nose (1.3.7)
        notebook (4.2.3)
        numba (0.28.1+0.gfe99fbc.dirty)
        numexpr (2.6.1)
        numpy (1.11.1)
        odo (0.5.0)
        openpyxl (2.3.2)
        pandas (0.18.1)
        partd (0.3.6)
        path.py (0.0.0)
        pathlib2 (2.1.0)
        patsy (0.4.1)
        pep8 (1.7.0)
        pickleshare (0.7.4)
        Pillow (3.3.1)
        pip (9.0.1)
        pkginfo (1.3.2)
        ply (3.9)
        prompt-toolkit (1.0.9)
        psutil (4.3.1)
        py (1.4.31)
        pyasn1 (0.1.9)
        pycosat (0.6.1)
        pycparser (2.14)
        pycrypto (2.6.1)
        pycurl (7.43.0)
        pyflakes (1.3.0)
        Pygments (2.1.3)
        pylint (1.5.4)
        pyOpenSSL (16.0.0)
        pyparsing (2.1.4)
        pytest (2.9.2)
        python-dateutil (2.5.3)
        pytz (2016.6.1)
        pywin32 (220)
        PyYAML (3.12)
        pyzmq (15.4.0)
        QtAwesome (0.3.3)
        qtconsole (4.2.1)
        QtPy (1.1.2)
        requests (2.11.1)
        rope (0.9.4)
        ruamel-yaml (-VERSION)
        scikit-image (0.12.3)
        scikit-learn (0.17.1)
        scipy (0.18.1)
        setuptools (27.2.0)
        simplegeneric (0.8.1)
        singledispatch (3.4.0.3)
        six (1.10.0)
        snowballstemmer (1.2.1)
        sockjs-tornado (1.0.3)
        sphinx (1.4.6)
        spyder (3.0.0)
        SQLAlchemy (1.0.13)
        statsmodels (0.6.1)
        sympy (1.0)
        tables (3.2.2)
        toolz (0.8.0)
        tornado (4.4.1)
        traitlets (4.3.0)
        unicodecsv (0.14.1)
        wcwidth (0.1.7)
        Werkzeug (0.11.11)
        wheel (0.29.0)
        widgetsnbextension (1.2.6)
        win-unicode-console (0.5)
        wrapt (1.10.6)
        xlrd (1.0.0)
        XlsxWriter (0.9.3)
        xlwings (0.10.0)
        xlwt (1.1.2)

Extracts: >>conda list:

    # packages in environment at C:\Anaconda2:
    #

    r                         3.3.1                  r3.3.1_0    r
    r-assertthat              0.1                    r3.3.1_2    r
    r-base                    3.3.1                         0    r
    r-base64enc               0.1_3                  r3.3.1_0    r
    r-bh                      1.60.0_2               r3.3.1_0    r
    r-bitops                  1.0_6                  r3.3.1_2    r
    r-boot                    1.3_18                 r3.3.1_0    r
    r-car                     2.1_2                  r3.3.1_0    r
    r-caret                   6.0_70                 r3.3.1_0    r
    r-catools                 1.17.1                 r3.3.1_2    r
    r-chron                   2.3_47                 r3.3.1_0    r
    r-class                   7.3_14                 r3.3.1_0    r
    r-cluster                 2.0.4                  r3.3.1_0    r
    r-codetools               0.2_14                 r3.3.1_0    r
    r-colorspace              1.2_6                  r3.3.1_0    r
    r-crayon                  1.3.1                  r3.3.1_0    r
    r-curl                    0.9.7                  r3.3.1_0    r
    r-data.table              1.9.6                  r3.3.1_0    r
    r-dbi                     0.4_1                  r3.3.1_0    r
    r-dichromat               2.0_0                  r3.3.1_2    r
    r-digest                  0.6.9                  r3.3.1_0    r
    r-dplyr                   0.4.3                  r3.3.1_0    r
    r-essentials              1.4.2                  r3.3.1_0    r
    r-evaluate                0.9                    r3.3.1_0    r
    r-foreach                 1.4.3                  r3.3.1_0    r
    r-foreign                 0.8_66                 r3.3.1_0    r
    r-formatr                 1.4                    r3.3.1_0    r
    r-ggplot2                 2.1.0                  r3.3.1_0    r
    r-gistr                   0.3.6                  r3.3.1_0    r
    r-glmnet                  2.0_5                  r3.3.1_0    r
    r-gtable                  0.2.0                  r3.3.1_0    r
    r-hexbin                  1.27.1                 r3.3.1_0    r
    r-highr                   0.6                    r3.3.1_0    r
    r-htmltools               0.3.5                  r3.3.1_0    r
    r-htmlwidgets             0.6                    r3.3.1_0    r
    r-httpuv                  1.3.3                  r3.3.1_0    r
    r-httr                    1.2.0                  r3.3.1_0    r
    r-irdisplay               0.4.3                  r3.3.1_2    r
    r-irkernel                0.7                    r3.3.1_2    r
    r-iterators               1.0.8                  r3.3.1_0    r
    r-jsonlite                0.9.22                 r3.3.1_0    r
    r-kernsmooth              2.23_15                r3.3.1_0    r
    r-knitr                   1.13                   r3.3.1_0    r
    r-labeling                0.3                    r3.3.1_2    r
    r-lattice                 0.20_33                r3.3.1_0    r
    r-lazyeval                0.2.0                  r3.3.1_0    r
    r-lme4                    1.1_12                 r3.3.1_0    r
    r-magrittr                1.5                    r3.3.1_2    r
    r-maps                    3.1.0                  r3.3.1_0    r
    r-markdown                0.7.7                  r3.3.1_2    r
    r-mass                    7.3_45                 r3.3.1_0    r
    r-matrix                  1.2_6                  r3.3.1_0    r
    r-matrixmodels            0.4_1                  r3.3.1_0    r
    r-memoise                 1.0.0                  r3.3.1_0    r
    r-mgcv                    1.8_12                 r3.3.1_0    r
    r-mime                    0.4                    r3.3.1_0    r
    r-minqa                   1.2.4                  r3.3.1_2    r
    r-munsell                 0.4.3                  r3.3.1_0    r
    r-nlme                    3.1_128                r3.3.1_0    r
    r-nloptr                  1.0.4                  r3.3.1_2    r
    r-nnet                    7.3_12                 r3.3.1_0    r
    r-openssl                 0.9.4                  r3.3.1_0    r
    r-pbdzmq                  0.2_3                  r3.3.1_0    r
    r-pbkrtest                0.4_6                  r3.3.1_0    r
    r-plyr                    1.8.4                  r3.3.1_0    r
    r-pryr                    0.1.2                  r3.3.1_0    r
    r-quantmod                0.4_5                  r3.3.1_2    r
    r-quantreg                5.26                   r3.3.1_0    r
    r-r6                      2.1.2                  r3.3.1_0    r
    r-randomforest            4.6_12                 r3.3.1_0    r
    r-rbokeh                  0.4.2                  r3.3.1_0    r
    r-rcolorbrewer            1.1_2                  r3.3.1_2    r
    r-rcpp                    0.12.5                 r3.3.1_0    r
    r-rcppeigen               0.3.2.8.1              r3.3.1_0    r
    r-recommended             3.3.1                  r3.3.1_0    r
    r-repr                    0.7                    r3.3.1_0    r
    r-reshape2                1.4.1                  r3.3.1_2    r
    r-rmarkdown               0.9.6                  r3.3.1_0    r
    r-rpart                   4.1_10                 r3.3.1_0    r
    r-scales                  0.4.0                  r3.3.1_0    r
    r-shiny                   0.13.2                 r3.3.1_0    r
    r-sparsem                 1.7                    r3.3.1_0    r
    r-spatial                 7.3_11                 r3.3.1_0    r
    r-stringi                 1.1.1                  r3.3.1_0    r
    r-stringr                 1.0.0                  r3.3.1_0    r
    r-survival                2.39_4                 r3.3.1_0    r
    r-tibble                  1.0                    r3.3.1_0    r
    r-tidyr                   0.5.1                  r3.3.1_0    r
    r-ttr                     0.23_1                 r3.3.1_0    r
    r-uuid                    0.1_2                  r3.3.1_0    r
    r-xtable                  1.8_2                  r3.3.1_0    r
    r-xts                     0.9_7                  r3.3.1_2    r
    r-yaml                    2.1.13                 r3.3.1_2    r
    r-zoo                     1.7_13                 r3.3.1_0    r

I have also an installation of Sage. However, it runs from a virtual box and is currently not running.

I am not sure, but I would like to think that GNU GCC, mingw, and/or RTools breaks the bind to R, because of some bug in Continuum's current dist. At the same time, I don't know if the R-essentials are related at all to the use of %.

Where's the magic?

Community
  • 1
  • 1
noumenal
  • 1,077
  • 2
  • 16
  • 36

2 Answers2

2

It definitely appears that rpy2 is taking over the role of the IPython R magic extension. What might be at issue is that you were attempting to install rpy2 via pip instead of using miniconda within your IPython environment. I have heard from a different part of the webs [reference below] that you need an install of rpy2 in your conda environment for the linkage to work properly. It will probably address your .dll lookup problems as well.

My suggestion (Windows):

activate ipykernel_py2
conda install -c r rpy2

and if that works out well, try:

jupyter notebook

The important thing is to be in your ipykernel_py2 environment when running jupyter.

ref: %load_ext rpy2.ipython Image not found error

Community
  • 1
  • 1
Robert Casey
  • 1,511
  • 18
  • 19
  • Brilliant, this worked on the second try! I used `conda list` to confirm that `rpy2` was installed. My home directory appears to have changed by running the server from a specific kernel (i.e. `(kernel_name) C:\dir\dir>`) and it seems that I am not able to run `activate` from a batch file, as the window closes, but yes - it works! – noumenal Dec 15 '16 at 09:35
0

If you've done pip install rpy2 then you need to load the extension before using it:

%load_ext rpy2.ipython
%%R
hobs
  • 18,473
  • 10
  • 83
  • 106