-->

rpy2 works in console, but cannot be imported by w

2019-09-02 14:56发布

问题:

I developed a web tool using CGI, python and apache.
The CGI file was written by python, and it calls R functions through rpy2.
The web tool works well on my personal computer.
Then we are trying to set it up on the server (System: CentOS release 5.7).
Since the version of python and R were old on the server, we installed latest Python and R and also rpy2 on the server(Python version: 2.7.8, R version 3.1.1 (2014-07-10), rpy2 version: 2.4.3).

But the web tool meet problems when it tries to import the rpy2 package.
However, I can call the same R codes in console from python.
The reported error by website is shown below.

message = '' 
output = 'Error in .Call("R_isMethodsDispatchOn", onOff, P...aseenv.get("show")\nLookupError:  \'show\' not found\n' 
returncode = 1

Does anyone have any ideas about that?

回答1:

Usually this means a mix up of R versions between build time and run time.

Make sure the same R is in the PATH (web servers can ohave a restricted PATH by default).



标签: python r cgi rpy2