Python3.6+R3.4环境下rpy2导入报错:Lookup Error: 'show' not found
I’ve run into this exact compatibility issue before with older Python/R and rpy2 combinations—here’s how to resolve it step by step:
Pin rpy2 to a compatible version
Newer rpy2 releases drop support for Python 3.6 and R 3.4. You need to install a version that explicitly supports this stack. Run these commands in your terminal:pip uninstall -y rpy2 pip install rpy2==2.9.6Version 2.9.6 is the last stable release that works reliably with Python 3.6 and R 3.4.
Set the R_HOME environment variable
Sometimes rpy2 can’t automatically locate your R installation. On macOS, set the path to your R 3.4 resources folder:export R_HOME=/Library/Frameworks/R.framework/Versions/3.4/ResourcesTo make this permanent, add the line above to your
~/.bash_profileor~/.zshrcfile (depending on your shell) and restart your terminal.Verify R’s core functions are intact
The "show" error can also happen if R’s base packages are corrupted. Open an R terminal and run:showYou should see output like
function (object) .Primitive("show"). If not, repair your R installation by reinstalling R 3.4 or runninginstall.packages("base", repos="https://cran.r-project.org")in R.Test the import again
After completing the steps above, launch Python and try importing again:import rpy2.robjects as robjectsThe warnings might still appear (they’re often just deprecation notices for older packages), but the "show" lookup error should be gone.
内容的提问来源于stack exchange,提问作者Jessica

