win7上安装rpy2, python环境是3.6.1。

使用pip install rpy2直接安装rpy2,对应的版本时rpy2 3.0.5

报如下错误:

ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\cparser.py", line 276, in _parse
ast = _get_parser().parse(fullcsource)
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\c_parser.py", line 152, in parse
debug=debuglevel)
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\ply\yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\ply\yacc.py", line 1199, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\ply\yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\c_parser.py", line 1761, in p_error
column=self.clex.find_tok_column(p)))
File "d:\python_virtualenv\pandas0192\lib\site-packages\pycparser\plyparser.py", line 66, in _parse_error
raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: <cdef source string>:23:5: before: blah1 During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-n564fvky\rpy2\setup.py", line 184, in <module>
'rpy2': ['doc/source/rpy2_logo.png', ]}
File "d:\python_virtualenv\pandas0192\lib\site-packages\setuptools\__init__.py", line 131, in setup
return distutils.core.setup(**attrs)
File "d:\program files\python361\Lib\distutils\core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "d:\python_virtualenv\pandas0192\lib\site-packages\setuptools\dist.py", line 370, in __init__
k: v for k, v in attrs.items()
File "d:\program files\python361\Lib\distutils\dist.py", line 281, in __init__
self.finalize_options()
File "d:\python_virtualenv\pandas0192\lib\site-packages\setuptools\dist.py", line 529, in finalize_options
ep.load()(self, ep.name, value)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\setuptools_ext.py", line 204, in cffi_modules
add_cffi_module(dist, cffi_module)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "rpy/_rinterface_cffi_build.py", line 546, in <module>
""" if os.name == 'nt' else ''
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\api.py", line 107, in cdef
self._cdef(csource, override=override, packed=packed)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\api.py", line 121, in _cdef
self._parser.parse(csource, override=override, **options)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\cparser.py", line 315, in parse
self._internal_parse(csource)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\cparser.py", line 320, in _internal_parse
ast, macros, csource = self._parse(csource)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\cparser.py", line 278, in _parse
self.convert_pycparser_error(e, csource)
File "d:\python_virtualenv\pandas0192\lib\site-packages\cffi\cparser.py", line 307, in convert_pycparser_error
raise CDefError(msg)
cffi.error.CDefError: cannot parse "blah1 ReadConsole;"
<cdef source string>:23:5: before: blah1
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-n564fvky\rpy2\

报错的大概意思是blah1 ReadConsole;这句话无法执行, 查看文件_rinterface_cffi_build.py,发现blah1这个类的定义在_rinterface_cffi_build.py文件中并没有。

在rpy2的最新的开源代码中,_rinterface_cffi_build.py文件中是有关于 "blah1"这个的定义的。源码网站地址: https://bitbucket.org/rpy2/rpy2/src/default/rpy/_rinterface_cffi_build.py

源码上是这样写的:

if os.name == 'nt':
ffibuilder.cdef("""
typedef int (*blah1) (const char *, char *, int, int);
typedef void (*blah2) (const char *, int);
typedef void (*blah3) (void);
typedef void (*blah4) (const char *);
/* Return value here is expected to be 1 for Yes, -1 for No and
* 0 for Cancel: symbolic constants in graphapp.h */
typedef int (*blah5) (const char *);
typedef void (*blah6) (int);
typedef void (*blah7) (const char *, int, int);
typedef enum {RGui, RTerm, LinkDLL} UImode; """)

然后我试了把开源代码直接下载下来,然后使用python setup.py install方式安装,rpy2这回可以正常安装上了。

然后检查一下可不可以使用:

>>> import rpy2
>>> from rpy2.robjects.packages import importr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "D:\python_virtualenv\nlp_learn\lib\site-packages\rpy2-3.1.0.dev0-py3.6.egg\rpy2\robjects\__init__.py", line 14, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "D:\python_virtualenv\nlp_learn\lib\site-packages\rpy2-3.1.0.dev0-py3.6.egg\rpy2\rinterface.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "D:\python_virtualenv\nlp_learn\lib\site-packages\rpy2-3.1.0.dev0-py3.6.egg\rpy2\rinterface_lib\openrlib.py", line 21, in <module>
File "D:\python_virtualenv\nlp_learn\lib\site-packages\rpy2-3.1.0.dev0-py3.6.egg\rpy2\rinterface_lib\openrlib.py", line 16, in _dlopen_rlib
File "D:\python_virtualenv\nlp_learn\lib\site-packages\rpy2-3.1.0.dev0-py3.6.egg\rpy2\situation.py", line 71, in get_rlib_path
ValueError: The system "%s" is not supported.

 得,(¬_¬),这意思是不支持当前的系统。 

 找了一个rpy2的文档,文档上是这么说的:

Microsoft’s Windows - unofficial and unsupported binaries are provided by Christoph Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/); there is otherwise currently close to no support for this platform
文档地址: https://rpy2.github.io/doc/latest/html/overview.html#installation

 就是说rpy2不支持windows这个平台,如果想要使用,请到https://www.lfd.uci.edu/~gohlke/pythonlibs/网站上去下载一个编译好的轮子。

这个网站上rpy2的最新版本是2.9.5, 选择好要下载的版本,选择好对应的系统, 下载完成后直接使用pip install + 轮子名称即可。

问题解决,早知道我直接去下个轮子就好了,还看了半天源码,浪费时间!!!

安装rpy2 报错<cdef source string>:23:5: before: blah1 解决办法就是直接下载一个rpy2的轮子的更多相关文章

  1. Scrapy安装报错 Microsoft Visual C++ 14.0 is required 解决办法

    Scrapy安装报错 Microsoft Visual C++ 14.0 is required 解决办法原因:Scrapy需要的组 twisted 需要 C++环境编译. 方法一:根据错误提示去对应 ...

  2. CocoaPods pod install的时候报错:invalid byte sequence in UTF-8 (ArgumentError)解决办法

    CocoaPods pod install的时候报错:invalid byte sequence in UTF-8 (ArgumentError)解决办法: 基本可以确定是Podfile中的内容编码有 ...

  3. 转 : Apache启动报错:could not bind to address [::]:443 解决办法

    转:Apache启动报错:could not bind to address [::]:443 解决办法 安装Apache服务器的时候,报如下错误: Installing the 'apache' s ...

  4. excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法

    excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法 office2007应该遇到“向程序发送命令时出现 问题”,设置为以管理员运行也不好用,重装office也不好用,下面介绍下 ...

  5. adb shell报错:error: insufficient permissions for device的解决办法

    1.错误描述 执行 adb shell 时,报错如下; error: insufficient permissions for device  2.解决办法 1,终端执行 lsusb 结果如下,注意绿 ...

  6. Win7 64bit 安装VisualSVN出现报错:Servic 'VisualSVN Server' failed to start.解决办法

    问题描述: Win7 64bit 安装VisualSVN时出现报错: Servic 'VisualSVN Server' failed to start.Please check VisualSVN ...

  7. java开发过程中,报错Dangling meta character '*' near index 0,解决办法

    1.split方法转化字符串为数组: String[] strPicArr = map.get("hw_pic").toString().split("*"); ...

  8. (转)PyCharm报错:“No R interpreter defined: Many R……”——解决办法

    报错截图: 下载安装链接:The Comprehensive R Archive Network

  9. Mac 升级后idea执行git命令报错xcrun: error: invalid active developer path的解决办法

    报错 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun ...

随机推荐

  1. DIJ的优化,和spfa的优化

    SPFA和DIJ求最短路的算法的坑点一直是很多的.经常会让人搞不懂. 易错案例: 用重载运算符来排序,如: struct cmp { bool operator ()(int x, int y) co ...

  2. python代码统计

    代码统计 修改filename为文件夹or文件地址,然后统计所有python文件代码 import os import sys def count_code_lines(filename): res ...

  3. AspNetCore3.0 和 JWT

    添加NuGet引用 IdentityModel Microsoft.AspNetCore.Authorization.JwtBearer 在appsettings.json中添加JwtBearer配置 ...

  4. jquery 如何在js中间加入css?

    ) { $() + 'rem' }) } ) { $( + '%' }) }

  5. 无法将“Scaffold-DbContext”项识别为 cmdlet、函数、脚本文件或可运行程序的名称...

    原文链接:https://my.oschina.net/taadis/blog/889560 为什么80%的码农都做不了架构师?>>>     PM> Scaffold-DbC ...

  6. #C++初学记录(N皇后#回溯递归)

    <font size=5 face"微软雅黑">N皇后Problem Description <font size=4 face"微软雅黑"& ...

  7. oracle 删除某个用户下的所有对象

    先存放好dropobj.sql 文件 然后登录需要删除的用户 删除前最好备份一下:(备份是在cmd中进行的) C:\Users\panfu>exp file=d:\expall.dmp log= ...

  8. MATLAB中 H(b > g) = 2*pi - H(b > g); 作何解

    H(b > g) = 2*pi - H(b > g); %b > g 会得到一个逻辑矩阵,如b=[7,5,6] ;g=[1,2,8],那么b>g会得到[1,1,0]: b< ...

  9. vue-使用keepAlive对上下拉刷新列表数据 和 滚动位置细节进行处理

    [前言] 使用vue处理项目中遇到列表页面时,有一些细节需要注意,这里总结一下,以便优化以后的代码.如下: 1. 使用mint-ui中的LoadMore组件上下拉刷新时,有时无法触发上拉加载更多的方法 ...

  10. pyqt5界面

    用pyqt5做了一个小程序,保留一下这个固定格式: import sys from PyQt5 import uic, QtGui from PyQt5.QtGui import QWindow fr ...