在 django 应用程序中使用 rpy 会抛出 RPy_Exception: R Function "get"未找到

发布于 2025-01-08 07:52:22 字数 2313 浏览 1 评论 0 原文

这是回溯(复制粘贴):

Traceback Switch to copy-and-paste view

/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in get_response
                    response = middleware_method(request) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/middleware/common.py in process_request
            if (not _is_valid_path(request.path_info, urlconf) and ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/middleware/common.py in _is_valid_path
        urlresolvers.resolve(path, urlconf) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
    return get_resolver(urlconf).resolve(path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
                    sub_match = pattern.resolve(new_path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
                    sub_match = pattern.resolve(new_path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
            return ResolverMatch(self.callback, args, kwargs, self.name) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in _get_callback
            self._callback = get_callable(self._callback_str) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/utils/functional.py in wrapper
        result = func(*args) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in get_callable
                lookup_view = getattr(import_module(mod_name), func_name) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py in import_module
    __import__(name) ...
▶ Local vars
/home/harsh/minip-server/website/Video_Performance/views.py in <module>
import datetime,rpy ...
▶ Local vars
/usr/lib/python2.6/dist-packages/rpy.py in <module>
r = R() ...
▶ Local vars
/usr/lib/python2.6/dist-packages/rpy.py in __init__
        self.get = _rpy.get_fun('get')  # this must happen before any calls to self or its methods! ...
▶ Local vars

有任何线索吗?

编辑: 这是代码,

import rpy

不要误会我的意思,这是错误所在的行。我尝试了一个单独的 python 提示符,并且 import rpy 没有失败。仅在网站上失败。为什么?

Here's the traceback(copy pasted):

Traceback Switch to copy-and-paste view

/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in get_response
                    response = middleware_method(request) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/middleware/common.py in process_request
            if (not _is_valid_path(request.path_info, urlconf) and ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/middleware/common.py in _is_valid_path
        urlresolvers.resolve(path, urlconf) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
    return get_resolver(urlconf).resolve(path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
                    sub_match = pattern.resolve(new_path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
                    sub_match = pattern.resolve(new_path) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in resolve
            return ResolverMatch(self.callback, args, kwargs, self.name) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in _get_callback
            self._callback = get_callable(self._callback_str) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/utils/functional.py in wrapper
        result = func(*args) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py in get_callable
                lookup_view = getattr(import_module(mod_name), func_name) ...
▶ Local vars
/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py in import_module
    __import__(name) ...
▶ Local vars
/home/harsh/minip-server/website/Video_Performance/views.py in <module>
import datetime,rpy ...
▶ Local vars
/usr/lib/python2.6/dist-packages/rpy.py in <module>
r = R() ...
▶ Local vars
/usr/lib/python2.6/dist-packages/rpy.py in __init__
        self.get = _rpy.get_fun('get')  # this must happen before any calls to self or its methods! ...
▶ Local vars

Any clue?

EDIT:
Here's the code

import rpy

don't get me wrong, it's the line the error is coming at. I tried on a separate python prompt and there import rpy does not fail. Only in the website it's failing. Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉宸 2025-01-15 07:52:22

这可能是一个多线程问题。对 R 的并发访问很糟糕(从“不要跨流,这会很糟糕”的意义上来说)。 rpy2 有一个锁定机制,每当发生异常时都会引发异常。

This might be a multhreading issue. Concurrent access to R is bad (in the "don't cross the streams, it would be bad" sense). rpy2 has a locking mechanism that should raise an Exception whenever it is about to happen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文