Python Windows 10上的Rmagics和Rpy2已损坏。所有计算结果都输出到Windows控制台,而不是Jupyter输出单元。RWinOut-hack不再有效

Python Windows 10上的Rmagics和Rpy2已损坏。所有计算结果都输出到Windows控制台,而不是Jupyter输出单元。RWinOut-hack不再有效,python,jupyter-notebook,ipython,rpy2,jupyter-contrib-nbextensions,Python,Jupyter Notebook,Ipython,Rpy2,Jupyter Contrib Nbextensions,Windows 10上的Rmagics和Rpy2已损坏。所有计算结果都输出到Windows控制台,而不是Jupyter输出单元。RWinOut黑客不再有效 一旦我使用RWinout,就会出现一个致命错误,需要我重新启动Jupyter NB服务器,它会杀死Jupyter笔记本Python内核 我尝试在3种不同的conda环境中安装,仅使用conda、Anaconda Navigator或pip。 安装完所有软件包后,它总是返回到相同的代码错误。有一些人提供了一步一步的手动程序来安装R,然后是rpy

Windows 10上的Rmagics和Rpy2已损坏。所有计算结果都输出到Windows控制台,而不是Jupyter输出单元。RWinOut黑客不再有效

一旦我使用RWinout,就会出现一个致命错误,需要我重新启动Jupyter NB服务器,它会杀死Jupyter笔记本Python内核

我尝试在3种不同的conda环境中安装,仅使用conda、Anaconda Navigator或pip。 安装完所有软件包后,它总是返回到相同的代码错误。有一些人提供了一步一步的手动程序来安装R,然后是rpy2,然后是特殊的支持包,然后是Jupyter,等等。这对于普通的数据科学家和分析人员来说太单调了

Rpy2需要重写以支持Windows 10

我希望这一切都能实现,因为Python-R NBs和Plotly Dash、Jupyter NB扩展(如Qgrid)以及其他功能可以很好地结合起来,实现丰富的交互式数据科学应用程序,而无需运行RShiny等其他服务器

我可以加载rpy2并使用它的函数和对象,但不能使用R cell magics

# 以下是我的版本信息:

R版本:('3','6.0','76424) Rpy2版本:2.9.4 Python 3.7.4版: jupyter核心:4.5.0 jupyter笔记本:6.0.1 QT控制台:4.5.5 伊皮顿:7.8.0 ipykernel:5.1.2 jupyter客户端:5.3.3 jupyter实验室:1.1.4 nbconvert:5.6.0 ipywidgets:7.5.1 格式:4.4.0 叛徒:4.3.3 7.8.0 所有内容都是使用Anaconda Navigator或命令控制台中的conda安装在此环境中的,除非没有conda包的内容需要pip安装

Conda是Jupyter生态系统的首选包管理器,因为它的设计与语言无关

# R内联magics将输出输出到Jupyter输出单元,但R单元magics将结果输出到我用来启动Jupyter笔记本的Windows控制台

只要我运行RWinOut,下面的错误就会出现,内核就会死掉

我还在Windows控制台中收到以下消息:

Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.8.0 (2020-02-14 07:10:20 UTC) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.23.0 successfully loaded. See ?R.oo for help.
Attaching package: 'R.oo'
The following object is masked from 'package:R.methodsS3':
    throw
The following objects are masked from 'package:methods':
    getClasses, getMethods
The following objects are masked from 'package:base':
    attach, detach, load, save
R.utils v2.9.2 successfully loaded. See ?R.utils for help.
Attaching package: 'R.utils'
The following object is masked from 'package:utils':
    timestamp
The following objects are masked from 'package:base':
    cat, commandArgs, getOption, inherits, isOpen, nullfile, parse,
    warnings
奇怪的是内联R魔法可以正常工作,但细胞魔法不行

当我按如下方式运行RWinOut时:

!curl -O "https://raw.githubusercontent.com/vitorcurtis/RWinOut/master/RWinOut.py"

%reload_ext RWinOut
我得到一长串错误(如下)。它还杀死了Jupyter NB的Python内核

rpy2.ipython扩展已加载。要重新加载,请使用: %重新加载\u ext rpy2.ipython


ValueError回溯(最近一次调用)
在里面
---->1 get_ipython()。运行线魔术('reload_ext','RWinOut'))
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\interactiveshell.py in run\u line\u magic(self,magic\u name,line,\u stack\u depth)
2312 kwargs['local\u ns']=sys.\u getframe(堆栈深度).f\u locals
2313带自建式存水弯:
->2314结果=fn(*args,**kwargs)
2315返回结果
2316
在reload_ext中(自身、模块_str)
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\magic.py in(f,*a,**k)
185#但就这一点来说就太过分了。
186 def魔术装饰(arg):
-->187调用=λf,*a,**k:f(*a,**k)
188
189如果可调用(arg):
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\magics\extension.py in reload\u ext(self,module\u str)
61如果不是模块_str:
62 raise UsageError('缺少模块名称')
--->63 self.shell.extension\u manager.reload\u extension(模块\u str)
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\extensions.py在reload\u扩展(self,module\u str)中
128自加载。添加(模块_str)
129其他:
-->130自加载扩展模块(模块)
131
132 def呼叫加载ipython分机(自身,mod):
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\extensions.py加载扩展(self,module\u str)
85 dir=compress\u user(self.ipython\u extension\u dir)))
86模=系统模件[模件]
--->87如果自动呼叫、加载、插拔分机(mod):
88自加载。添加(模块_str)
89.其他:
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\extensions.py in\u call\u load\u IPython\u extension(self,mod)
132 def呼叫加载ipython分机(自身,mod):
133如果hasattr(mod“load_ipython_extension”):
-->134模块加载ipython扩展(self.shell)
135返回真值
136
c:\Users\rlysakow\Desktop\00 PayEquity WIP\RWinOut.py加载ip扩展(ip)
39#加载魔法和库
40 ip.run\u line\u magic('load\u ext','rpy2.ipython')
--->41 ip.运行\u行\u魔术('R'、'library(R.utils)')
42 ip.run\u line\u magic('config','Application.verbose\u crash=True'))
43
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\interactiveshell.py in run\u line\u magic(self,magic\u name,line,\u stack\u depth)
2312 kwargs['local\u ns']=sys.\u getframe(堆栈深度).f\u locals
2313带自建式存水弯:
->2314结果=fn(*args,**kwargs)
2315返回结果
2316
在R中(自身、线路、单元、局部)
C:\ProgramData\Anaconda3\lib\site packages\IPython\core\magic.py in(f,*a,**k)
185#但就这一点来说就太过分了。
186 def魔术装饰(arg):
-->187调用=λf,*a,**k:f(*a,**k)
188
189如果可调用(arg):
C:\ProgramData\Anaconda3\lib\site packages\rpy2\ipython\rmagic.py in R(self、line、cell、local\n)
755如果结果不是ri.NULL:
756,本地转换器(转换器)作为cv:
-->757 res=cv.ri2py(结果)
758返回res
759
C:\ProgramData\Anaconda3\lib\functools
ValueError                                Traceback (most recent call last)
<ipython-input-25-49c9701f263c> in <module>
----> 1 get_ipython().run_line_magic('reload_ext', 'RWinOut')

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2312                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2313             with self.builtin_trap:
-> 2314                 result = fn(*args, **kwargs)
   2315             return result
   2316 

<C:\ProgramData\Anaconda3\lib\site-packages\decorator.py:decorator-gen-67> in reload_ext(self, module_str)

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magics\extension.py in reload_ext(self, module_str)
     61         if not module_str:
     62             raise UsageError('Missing module name.')
---> 63         self.shell.extension_manager.reload_extension(module_str)

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\extensions.py in reload_extension(self, module_str)
    128                 self.loaded.add(module_str)
    129         else:
--> 130             self.load_extension(module_str)
    131 
    132     def _call_load_ipython_extension(self, mod):

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\extensions.py in load_extension(self, module_str)
     85                               dir=compress_user(self.ipython_extension_dir)))
     86             mod = sys.modules[module_str]
---> 87             if self._call_load_ipython_extension(mod):
     88                 self.loaded.add(module_str)
     89             else:

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\extensions.py in _call_load_ipython_extension(self, mod)
    132     def _call_load_ipython_extension(self, mod):
    133         if hasattr(mod, 'load_ipython_extension'):
--> 134             mod.load_ipython_extension(self.shell)
    135             return True
    136 

c:\Users\rlysakow\Desktop\00-PayEquity-WIP\RWinOut.py in load_ipython_extension(ip)
     39         # loading magic and libraries
     40         ip.run_line_magic('load_ext', 'rpy2.ipython')
---> 41         ip.run_line_magic('R', 'library(R.utils)')
     42         ip.run_line_magic('config', 'Application.verbose_crash=True')
     43 

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2312                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2313             with self.builtin_trap:
-> 2314                 result = fn(*args, **kwargs)
   2315             return result
   2316 

<C:\ProgramData\Anaconda3\lib\site-packages\decorator.py:decorator-gen-133> in R(self, line, cell, local_ns)

C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

C:\ProgramData\Anaconda3\lib\site-packages\rpy2\ipython\rmagic.py in R(self, line, cell, local_ns)
    755             if result is not ri.NULL:
    756                 with localconverter(converter) as cv:
--> 757                     res = cv.ri2py(result)
    758                 return res
    759 

C:\ProgramData\Anaconda3\lib\functools.py in wrapper(*args, **kw)
    838                             '1 positional argument')
    839 
--> 840         return dispatch(args[0].__class__)(*args, **kw)
    841 
    842     funcname = getattr(func, '__name__', 'singledispatch function')

C:\ProgramData\Anaconda3\lib\site-packages\rpy2\robjects\pandas2ri.py in ri2py_vector(obj)
    137 @ri2py.register(SexpVector)
    138 def ri2py_vector(obj):
--> 139     res = numpy2ri.ri2py(obj)
    140     return res
    141 

C:\ProgramData\Anaconda3\lib\functools.py in wrapper(*args, **kw)
    838                             '1 positional argument')
    839 
--> 840         return dispatch(args[0].__class__)(*args, **kw)
    841 
    842     funcname = getattr(func, '__name__', 'singledispatch function')

C:\ProgramData\Anaconda3\lib\site-packages\rpy2\robjects\numpy2ri.py in ri2py_sexp(obj)
    157 def ri2py_sexp(obj):
    158     if (obj.typeof in _vectortypes) and (obj.typeof != VECSXP):
--> 159         res = numpy.asarray(obj)
    160     else:
    161         res = ro.default_converter.ri2py(obj)

C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\numeric.py in asarray(a, dtype, order)
    536 
    537     """
--> 538     return array(a, dtype, copy=False, order=order)
    539 
    540 

ValueError: Buffer for this type not yet supported.