在 win7 上安装 rpy2 时遇到问题(R 2.12,Python 2.5)

2022-01-18 00:00:00 python matplotlib r windows-7 rpy2

问题描述

我是 Python 的新手(和一般的编程)我来自金融背景,所以请多多包涵.我刚开始使用 Python(Enthought 的 Pylab/Scipy/Numpy)和 R 进行统计分析.我正在尝试将 rpy2 安装到 Python 中以集成 R,但出现错误:

<块引用>

试图猜测 R 的 HOME 但没有 RPATH 中的命令.

我不确定这意味着什么.如果有用的话,我的 R.exe 的路径是C:Program FilesRR-2.12.1in".任何帮助将不胜感激!

这里是 setup.py 的代码

import os, os.path, sys, shutil, re, itertools从 distutils.command.build_ext 导入 build_ext 作为 _build_ext从 distutils.command.build 导入构建为 _build从 distutils.core 导入设置从 distutils.core 导入扩展pack_name = 'rpy2'pack_version = __import__('rpy').__version__类构建(_build):user_options = _build.user_options + [#('r-autoconfig', 无,# "猜测所有配置路径" +# "在 PATH 中找到的 R 可执行文件" +# "(这会覆盖 r-home)"),('r-home=', 无,"R home 编译的完整路径" +(请参阅 r-autoconfig 了解自动配置)"),('r-home-lib=', 无,"R 共享 lib/目录的完整路径" +"(<r-home>/lib 否则)"),('r-home-modules=', 无,"R 共享模块/目录的完整路径" +"(<r-home>/modules 否则)")]boolean_options = _build.boolean_options #+ #['r-autoconfig', ]定义初始化选项(自我):_build.initialize_options(self)self.r_autoconfig = 无self.r_home = 无self.r_home_lib = 无self.r_home_modules = 无类 build_ext(_build_ext):"""-DRPY_VERBOSE-DRPY_DEBUG_PRESERV-DRPY_DEBUG_PROMISE : 评估承诺-DRPY_DEBUG_OBJECTINIT : PySexpObject 的初始化-DRPY_DEBUG_CONSOLE:控制台 I/O-DRPY_DEBUG_COBJECT:SexpObject 作为 CObject 传递-DRPY_DEBUG_GRDEV"""user_options = _build_ext.user_options + [#('r-autoconfig', 无,# "猜测所有配置路径" +# "在 PATH 中找到的 R 可执行文件" +# "(这会覆盖 r-home)"),('r-home=', 无,"R home 编译的完整路径" +(请参阅 r-autoconfig 了解自动配置)"),('r-home-lib=', 无,"R 共享 lib/目录的完整路径" +"(<r-home>/lib 否则)"),('r-home-modules=', 无,R 共享模块/目录的完整路径"+"(<r-home>/modules 否则)")]boolean_options = _build_ext.boolean_options #+ #['r-autoconfig', ]定义初始化选项(自我):_build_ext.initialize_options(self)self.r_autoconfig = 无self.r_home = 无self.r_home_lib = 无self.r_home_modules = 无def finalize_options(self):self.set_undefined_options('build',#('r_autoconfig', 'r_autoconfig'),('r_home', 'r_home'))_build_ext.finalize_options(self)如果 self.r_home 为无:self.r_home = os.popen("R RHOME").readlines()如果 len(self.r_home) == 0:raise SystemExit("错误:试图猜测 R 的 HOME 但路径中没有 R 命令.")#Twist if 'R RHOME' 吐出警告如果 self.r_home[0].startswith("WARNING"):self.r_home = self.r_home[1]别的:self.r_home = self.r_home[0]#self.r_home = [self.r_home, ]如果 self.r_home 为无:raise SystemExit("错误:--r-home 未指定.")别的:self.r_home = self.r_home.split(os.pathsep)版本 = []对于 self.r_home 中的 r_home:r_home = r_home.strip()rversion = get_rversion(r_home)如果 cmp_version(rversion[:2], [2, 8]) == -1:raise SystemExit("错误:需要 R >= 2.8.")rversions.append(rversion)配置 = RConfig()for about in ('--ldflags', '--cppflags','LAPACK_LIBS'、'BLAS_LIBS'):config += get_rconfig(r_home, about)打印(配置.__repr__())self.include_dirs.extend(config._include_dirs)self.libraries.extend(config._libraries)self.library_dirs.extend(config._library_dirs)如果 self.r_home_modules 为无:self.library_dirs.extend([os.path.join(r_home, 'modules'), ])别的:self.library_dirs.extends([self.r_home_modules, ])#for e in self.extensions:# self.extra_link_args.extra_link_args(config.extra_link_args)# e.extra_compile_args.extend(extra_compile_args)定义运行(自我):_build_ext.run(self)def get_rversion(r_home):r_exec = os.path.join(r_home, 'bin', 'R')# 如果 Win32 则扭曲如果 sys.platform == "win32":rp = os.popen3('"'+r_exec+'" --version')[2]别的:rp = os.popen('"'+r_exec+'" --version')rversion = rp.readline()#Twist if 'R RHOME' 吐出警告如果 rversion.startswith("警告"):rversion = rp.readline()m = re.match('^R 版本 ([^ ]+) .+$', rversion)rversion = m.groups()[0]rversion = rversion.split('.')rversion[0] = int(rversion[0])rversion[1] = int(rversion[1])返回版本def cmp_version(x, y):如果 (x[0] < y[0]):返回 -1如果(x[0] > y[0]):返回 1如果(x[0] == y[0]):如果 len(x) == 1 或 len(y) == 1:返回 0返回 cmp_version(x[1:], y[1:])类 RConfig(对象):_include_dirs = 无_libraries = 无_library_dirs = 无_extra_link_args = 无_frameworks = 无_framework_dirs = 无def __init__(self,include_dirs = 元组(),库 = 元组(),library_dirs = tuple(), extra_link_args = tuple(),框架=元组(),framework_dirs = 元组()):for k in ('include_dirs', 'libraries','library_dirs'、'extra_link_args'):v = 本地人()[k]如果不是 isinstance(v, tuple):如果是实例(v,str):v = [v, ]v = 元组(集合(v))self.__dict__['_'+k] = v# 框架特定于 OSX对于 k in ('framework_dirs', 'frameworks'):v = 本地人()[k]如果不是 isinstance(v, tuple):如果是实例(v,str):v = [v, ]v = 元组(集合(v))self.__dict__['_'+k] = vself.__dict__['_'+'extra_link_args'] = 元组(set(v + self.__dict__['_'+'extra_link_args']))def __repr__(self):s = 'R 作为库的配置:' + os.lineseps += os.linesep.join([' ' + x + ': ' + self.__dict__['_'+x].__repr__() for x in ('include_dirs', 'libraries','library_dirs', 'extra_link_args')])s += os.linesep + ' # OSX 特定(包含在 extra_link_args 中)' + os.lineseps += os.linesep.join([' ' + x + ': ' + self.__dict__['_'+x].__repr__() 对于 x in ('framework_dirs', 'frameworks')])返回def __add__(self, config):断言 isinstance(config, RConfig)res = RConfig(include_dirs = self._include_dirs + config._include_dirs,库 = self._libraries + config._libraries,library_dirs = self._library_dirs + config._library_dirs,extra_link_args = self._extra_link_args + config._extra_link_args)返回资源@静态方法def from_string(string, allow_empty = False):possible_patterns = ('^-L(?P<library_dirs>[^]+)$','^-l(?P<库>[^]+)$','^-I(?P[^]+)$','^(?P-F[^]+?)$','^(?P-framework [^]+)$')pp = [re.compile(x) for x in possible_patterns]# 对返回到 rconfig 的内容进行完整性检查rconfig_m = 无跨度 = (0, 0)rc = RConfig()对于 re.split('(?<!-framework) ', string) 中的子字符串:好的 = 假对于 pp 中的模式:rconfig_m = pattern.match(子字符串)如果 rconfig_m 不是无:rc += RConfig(**rconfig_m.groupdict())跨度 = rconfig_m.span()好的 = 真休息elif rconfig_m 为无:如果 allow_empty 和 (rconfig == ''):print(cmd + '
返回一个空字符串.
')rc += RConfig()好的 = 真休息别的:# 如果配置指向现有库,# 用它如果 os.path.exists(string):rc += RConfig(库 = 子字符串)好的 = 真休息如果不行:raise ValueError('无效的子字符串
' + 子字符串+ '
in 字符串
' + 字符串)返回 rcdef get_rconfig(r_home, about, allow_empty = False):r_exec = os.path.join(r_home, 'bin', 'R')cmd = '"'+r_exec+'" CMD 配置 '+aboutrp = os.popen(cmd)rconfig = rp.readline()#Twist if 'R RHOME' 吐出警告如果 rconfig.startswith("警告"):rconfig = rp.readline()rconfig = rconfig.strip()rc = RConfig.from_string(rconfig)返回 rcdef getRinterface_ext():#r_libs = [os.path.join(RHOME, 'lib'), os.path.join(RHOME, 'modules')]r_libs = []extra_link_args = []#FIXME:粗略的方式(在很多情况下会中断)#check how to get how to have a configure step定义宏 = []如果 sys.platform == 'win32':define_macros.append(('Win32', 1))别的:define_macros.append(('R_INTERFACE_PTRS', 1))define_macros.append(('HAVE_POSIX_SIGJMP', 1))define_macros.append(('CSTACK_DEFNS', 1))define_macros.append(('RIF_HAS_RSIGHAND', 1))包含目录 = []rinterface_ext = 扩展(名称 = pack_name + '.rinterface.rinterface',来源 = [ #os.path.join('rpy', 'rinterface', 'embeddedr.c'),#os.path.join('rpy', 'rinterface', 'r_utils.c'),#os.path.join('rpy', 'rinterface', 'buffer.c'),#os.path.join('rpy', 'rinterface', 'sequence.c'),#os.path.join('rpy', 'rinterface', 'sexp.c'),os.path.join('rpy', 'rinterface', 'rinterface.c')],依赖 = [os.path.join('rpy', 'rinterface', 'embeddedr.h'),os.path.join('rpy', 'rinterface', 'r_utils.h'),os.path.join('rpy', 'rinterface', 'buffer.h'),os.path.join('rpy', 'rinterface', 'sequence.h'),os.path.join('rpy', 'rinterface', 'sexp.h'),os.path.join('rpy', 'rinterface', 'rpy_rinterface.h')],include_dirs = [os.path.join('rpy', 'rinterface'),] + include_dirs,库 = ['R', ],library_dirs = r_libs,定义宏 = 定义宏,runtime_library_dirs = r_libs,#extra_compile_args=['-O0', '-g'],#extra_link_args = extra_link_args)rpy_device_ext = 扩展(pack_name + '.rinterface.rpy_device',[os.path.join('rpy', 'rinterface', 'rpy_device.c'),],包含目录 = 包含目录 +[os.path.join('rpy', 'rinterface'), ],库 = ['R', ],library_dirs = r_libs,定义宏 = 定义宏,runtime_library_dirs = r_libs,#extra_compile_args=['-O0', '-g'],extra_link_args = extra_link_args)返回 [rinterface_ext, rpy_device_ext]rinterface_exts = []ri_ext = getRinterface_ext()rinterface_exts.append(ri_ext)pack_dir = {pack_name: 'rpy'}导入 distutils.command.install对于 distutils.command.install.INSTALL_SCHEMES.values() 中的方案:方案['data'] = 方案['purelib']设置(#install_requires=['分发'],cmdclass = {'build':构建,'build_ext': build_ext},名称 = 包装名称,版本 = 包版本,description = "R 语言的 Python 接口",url = "http://rpy.sourceforge.net",license = "AGPLv3.0 (除了 rpy2.rinterface: LGPL)",作者=洛朗戈蒂埃",author_email = "lgautier@gmail.com",ext_modules = rinterface_exts[0],包目录 = 包目录,包 = [包名,pack_name + '.rlike',pack_name + '.rlike.tests',pack_name + '.rinterface',pack_name + '.rinterface.tests',pack_name + '.robjects',pack_name + '.robjects.tests',pack_name + '.robjects.lib',],分类器 = ['编程语言 :: Python','许可证 :: OSI 已批准 :: GNU 库或较小的通用公共许可证 (LGPL)','许可证 :: OSI 批准 :: GNU Affero 通用公共许可证 v3',目标受众:开发人员",目标受众:: 科学/研究",'开发状态 :: 5 - 生产/稳定'],data_files = [(os.path.join('rpy2', 'images'),[os.path.join('doc', 'source', 'rpy2_logo.png')])]#[pack_name + '.rinterface_' + x for x in rinterface_rversions] + #[pack_name + '.rinterface_' + x + '.tests' for x in rinterface_rversions])

解决方案

我知道我参加聚会有点晚了,但我遇到了同样的问题,并通过 conda 进行安装使其在 Windows 7 上运行

p>

conda install --channel https://conda.binstar.org/joshadel rpy2

I'm brand new to Python (and programming in general) I come from a finance background, so please bear with me. I just started using Python (Enthought's Pylab/Scipy/Numpy) and R for statistical analysis. I'm trying to install rpy2 into Python to integrate R, but I get the error:

Tried to guess R's HOME but no R command in the PATH.

I'm not sure what this means. The path to my R.exe is "C:Program FilesRR-2.12.1in" if that's useful. Any help would be much appreciated!

Here's setup.py's code

import os, os.path, sys, shutil, re, itertools
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.build import build as _build

from distutils.core import setup
from distutils.core import Extension


pack_name = 'rpy2'
pack_version = __import__('rpy').__version__


class build(_build):
    user_options = _build.user_options + 
        [
        #('r-autoconfig', None,
        # "guess all configuration paths from " +
        #     "the R executable found in the PATH " +
        #     "(this overrides r-home)"),
        ('r-home=', None, 
         "full path for the R home to compile against " +
             "(see r-autoconfig for an automatic configuration)"),
        ('r-home-lib=', None,
         "full path for the R shared lib/ directory " +
             "(<r-home>/lib otherwise)"),
        ('r-home-modules=', None,
         "full path for the R shared modules/ directory " +
             "(<r-home>/modules otherwise)") 
        ]
    boolean_options = _build.boolean_options #+ 
        #['r-autoconfig', ]


    def initialize_options(self):
        _build.initialize_options(self)
        self.r_autoconfig = None
        self.r_home = None
        self.r_home_lib = None
        self.r_home_modules = None

class build_ext(_build_ext):
    """
    -DRPY_VERBOSE
    -DRPY_DEBUG_PRESERV
    -DRPY_DEBUG_PROMISE    : evaluation of promises
    -DRPY_DEBUG_OBJECTINIT : initialization of PySexpObject
    -DRPY_DEBUG_CONSOLE    : console I/O
    -DRPY_DEBUG_COBJECT    : SexpObject passed as a CObject
    -DRPY_DEBUG_GRDEV
    """
    user_options = _build_ext.user_options + 
        [
        #('r-autoconfig', None,
        #  "guess all configuration paths from " +
        #      "the R executable found in the PATH " +
        #      "(this overrides r-home)"),
        ('r-home=', None, 
         "full path for the R home to compile against " +
             "(see r-autoconfig for an automatic configuration)"),
        ('r-home-lib=', None,
         "full path for the R shared lib/ directory" +
             "(<r-home>/lib otherwise)"),
        ('r-home-modules=', None,
         "full path for the R shared modules/ directory" +
             "(<r-home>/modules otherwise)")]

    boolean_options = _build_ext.boolean_options #+ 
        #['r-autoconfig', ]

    def initialize_options(self):
        _build_ext.initialize_options(self)
        self.r_autoconfig = None
        self.r_home = None
        self.r_home_lib = None
        self.r_home_modules = None

    def finalize_options(self):
        self.set_undefined_options('build',
                                   #('r_autoconfig', 'r_autoconfig'),
                                   ('r_home', 'r_home'))
        _build_ext.finalize_options(self) 
        if self.r_home is None:
            self.r_home = os.popen("R RHOME").readlines()
            if len(self.r_home) == 0:
                raise SystemExit("Error: Tried to guess R's HOME but no R command in the PATH.")

    #Twist if 'R RHOME' spits out a warning
            if self.r_home[0].startswith("WARNING"):
                self.r_home = self.r_home[1]
            else:
                self.r_home = self.r_home[0]
            #self.r_home = [self.r_home, ]

        if self.r_home is None:
            raise SystemExit("Error: --r-home not specified.")
        else:
            self.r_home = self.r_home.split(os.pathsep)

        rversions = []
        for r_home in self.r_home:
            r_home = r_home.strip()
        rversion = get_rversion(r_home)
        if cmp_version(rversion[:2], [2, 8]) == -1:
            raise SystemExit("Error: R >= 2.8 required.")
        rversions.append(rversion)

        config = RConfig()
        for about in ('--ldflags', '--cppflags', 
                      'LAPACK_LIBS', 'BLAS_LIBS'):
            config += get_rconfig(r_home, about)

        print(config.__repr__())

        self.include_dirs.extend(config._include_dirs)
        self.libraries.extend(config._libraries)
        self.library_dirs.extend(config._library_dirs)

        if self.r_home_modules is None:
            self.library_dirs.extend([os.path.join(r_home, 'modules'), ])
        else:
            self.library_dirs.extends([self.r_home_modules, ])

        #for e in self.extensions:
        #    self.extra_link_args.extra_link_args(config.extra_link_args)
        #    e.extra_compile_args.extend(extra_compile_args)

    def run(self):
        _build_ext.run(self)



def get_rversion(r_home):
    r_exec = os.path.join(r_home, 'bin', 'R')
    # Twist if Win32
    if sys.platform == "win32":
        rp = os.popen3('"'+r_exec+'" --version')[2]
    else:
        rp = os.popen('"'+r_exec+'" --version')
    rversion = rp.readline()
    #Twist if 'R RHOME' spits out a warning
    if rversion.startswith("WARNING"):
        rversion = rp.readline()
    m = re.match('^R version ([^ ]+) .+$', rversion)
    rversion = m.groups()[0]
    rversion = rversion.split('.')
    rversion[0] = int(rversion[0])
    rversion[1] = int(rversion[1])
    return rversion

def cmp_version(x, y):
    if (x[0] < y[0]):
        return -1
    if (x[0] > y[0]):
        return 1
    if (x[0] == y[0]):
        if len(x) == 1 or len(y) == 1:
            return 0
        return cmp_version(x[1:], y[1:])

class RConfig(object):
    _include_dirs = None
    _libraries = None
    _library_dirs = None 
    _extra_link_args = None
    _frameworks = None
    _framework_dirs = None
    def __init__(self,
                 include_dirs = tuple(), libraries = tuple(),
                 library_dirs = tuple(), extra_link_args = tuple(),
                 frameworks = tuple(),
                 framework_dirs = tuple()):
        for k in ('include_dirs', 'libraries', 
                  'library_dirs', 'extra_link_args'):
            v = locals()[k]
            if not isinstance(v, tuple):
                if isinstance(v, str):
                    v = [v, ]
            v = tuple(set(v))
            self.__dict__['_'+k] = v
        # frameworks are specific to OSX
        for k in ('framework_dirs', 'frameworks'):
            v = locals()[k]
            if not isinstance(v, tuple):
                if isinstance(v, str):
                    v = [v, ]
            v = tuple(set(v))
            self.__dict__['_'+k] = v
            self.__dict__['_'+'extra_link_args'] = tuple(set(v + self.__dict__['_'+'extra_link_args']))


    def __repr__(self):
        s = 'Configuration for R as a library:' + os.linesep
        s += os.linesep.join(
            ['  ' + x + ': ' + self.__dict__['_'+x].__repr__() 
                 for x in ('include_dirs', 'libraries',
                           'library_dirs', 'extra_link_args')])
        s += os.linesep + ' # OSX-specific (included in extra_link_args)' + os.linesep 
        s += os.linesep.join(
            ['  ' + x + ': ' + self.__dict__['_'+x].__repr__() 
                 for x in ('framework_dirs', 'frameworks')]
            )

        return s

    def __add__(self, config):
        assert isinstance(config, RConfig)
        res = RConfig(include_dirs = self._include_dirs + 
                          config._include_dirs,
                      libraries = self._libraries + config._libraries,
                      library_dirs = self._library_dirs + 
                          config._library_dirs,
                      extra_link_args = self._extra_link_args + 
                          config._extra_link_args)
        return res
    @staticmethod
    def from_string(string, allow_empty = False):
        possible_patterns = ('^-L(?P<library_dirs>[^ ]+)$',
                             '^-l(?P<libraries>[^ ]+)$',
                             '^-I(?P<include_dirs>[^ ]+)$',
                             '^(?P<framework_dirs>-F[^ ]+?)$',
                             '^(?P<frameworks>-framework [^ ]+)$')
        pp = [re.compile(x) for x in possible_patterns]
        # sanity check of what is returned into rconfig
        rconfig_m = None        
        span = (0, 0)
        rc = RConfig()
        for substring in re.split('(?<!-framework) ', string):
            ok = False
            for pattern in pp:
                rconfig_m = pattern.match(substring)
                if rconfig_m is not None:
                    rc += RConfig(**rconfig_m.groupdict())
                    span = rconfig_m.span()
                    ok = True
                    break
                elif rconfig_m is None:
                    if allow_empty and (rconfig == ''):
                        print(cmd + '
returned an empty string.
')
                        rc += RConfig()
                        ok = True
                        break
                    else:
                        # if the configuration points to an existing library, 
                        # use it
                        if os.path.exists(string):
                            rc += RConfig(library = substring)
                            ok = True
                            break
            if not ok:
                raise ValueError('Invalid substring
' + substring 
                                 + '
in string
' + string)
        return rc

def get_rconfig(r_home, about, allow_empty = False):
    r_exec = os.path.join(r_home, 'bin', 'R')
    cmd = '"'+r_exec+'" CMD config '+about
    rp = os.popen(cmd)
    rconfig = rp.readline()
    #Twist if 'R RHOME' spits out a warning
    if rconfig.startswith("WARNING"):
        rconfig = rp.readline()
    rconfig = rconfig.strip()
    rc = RConfig.from_string(rconfig)
    return rc


def getRinterface_ext():
    #r_libs = [os.path.join(RHOME, 'lib'), os.path.join(RHOME, 'modules')]
    r_libs = []
    extra_link_args = []

    #FIXME: crude way (will break in many cases)
    #check how to get how to have a configure step
    define_macros = []

    if sys.platform == 'win32':
        define_macros.append(('Win32', 1))
    else:
        define_macros.append(('R_INTERFACE_PTRS', 1))
        define_macros.append(('HAVE_POSIX_SIGJMP', 1))

    define_macros.append(('CSTACK_DEFNS', 1))
    define_macros.append(('RIF_HAS_RSIGHAND', 1))

    include_dirs = []

    rinterface_ext = Extension(
            name = pack_name + '.rinterface.rinterface',
            sources = [ 
            #os.path.join('rpy', 'rinterface', 'embeddedr.c'), 
            #os.path.join('rpy', 'rinterface', 'r_utils.c'),
            #os.path.join('rpy', 'rinterface', 'buffer.c'),
            #os.path.join('rpy', 'rinterface', 'sequence.c'),
            #os.path.join('rpy', 'rinterface', 'sexp.c'),
            os.path.join('rpy', 'rinterface', 'rinterface.c')
                       ],
            depends = [os.path.join('rpy', 'rinterface', 'embeddedr.h'), 
                       os.path.join('rpy', 'rinterface', 'r_utils.h'),
                       os.path.join('rpy', 'rinterface', 'buffer.h'),
                       os.path.join('rpy', 'rinterface', 'sequence.h'),
                       os.path.join('rpy', 'rinterface', 'sexp.h'),
                       os.path.join('rpy', 'rinterface', 'rpy_rinterface.h')
                       ],
            include_dirs = [os.path.join('rpy', 'rinterface'),] + include_dirs,
            libraries = ['R', ],
            library_dirs = r_libs,
            define_macros = define_macros,
            runtime_library_dirs = r_libs,
            #extra_compile_args=['-O0', '-g'],
            #extra_link_args = extra_link_args
            )

    rpy_device_ext = Extension(
        pack_name + '.rinterface.rpy_device',
            [
            os.path.join('rpy', 'rinterface', 'rpy_device.c'),
             ],
            include_dirs = include_dirs + 
                            [os.path.join('rpy', 'rinterface'), ],
            libraries = ['R', ],
            library_dirs = r_libs,
            define_macros = define_macros,
            runtime_library_dirs = r_libs,
            #extra_compile_args=['-O0', '-g'],
            extra_link_args = extra_link_args
        )

    return [rinterface_ext, rpy_device_ext]


rinterface_exts = []
ri_ext = getRinterface_ext()
rinterface_exts.append(ri_ext)

pack_dir = {pack_name: 'rpy'}

import distutils.command.install
for scheme in distutils.command.install.INSTALL_SCHEMES.values():
    scheme['data'] = scheme['purelib']

setup(
    #install_requires=['distribute'],
    cmdclass = {'build': build,
                'build_ext': build_ext},
    name = pack_name,
    version = pack_version,
    description = "Python interface to the R language",
    url = "http://rpy.sourceforge.net",
    license = "AGPLv3.0 (except rpy2.rinterface: LGPL)",
    author = "Laurent Gautier",
    author_email = "lgautier@gmail.com",
    ext_modules = rinterface_exts[0],
    package_dir = pack_dir,
    packages = [pack_name,
                pack_name + '.rlike',
                pack_name + '.rlike.tests',
                pack_name + '.rinterface',
                pack_name + '.rinterface.tests',
                pack_name + '.robjects',
                pack_name + '.robjects.tests',
                pack_name + '.robjects.lib',
                ],
    classifiers = ['Programming Language :: Python',
                   'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
                   'License :: OSI Approved :: GNU Affero General Public License v3',
                   'Intended Audience :: Developers',
                   'Intended Audience :: Science/Research',
                   'Development Status :: 5 - Production/Stable'
                   ],
    data_files = [(os.path.join('rpy2', 'images'), 
                   [os.path.join('doc', 'source', 'rpy2_logo.png')])]

    #[pack_name + '.rinterface_' + x for x in rinterface_rversions] + 
        #[pack_name + '.rinterface_' + x + '.tests' for x in rinterface_rversions]
    )

解决方案

I know I'm a little late to the party, but I had the same problem and got it working on Windows 7 by doing the install via conda

conda install --channel https://conda.binstar.org/joshadel rpy2

相关文章