python - 无法在 MAC OS 中通过 pip 安装 rpy2

标签 python r macos pycharm rpy2

我无法在 MAC OS 中通过 pip 或 PyCharm 安装 rpy2(Python 包)。
但我可以成功运行Python(通过PyCharm)和R(通过RStudio)......
主要错误信息是

"Error: Tried to guess R's HOME but no command (R) in the PATH." and "Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-OtKzsd/rpy2/".

我猜问题可能与 R 环境 PATH 设置有关?
但我还是不知道如何解决这个问题......
完整的错误消息如下:

host-217:~ ChenGuanYing$ sudo pip install rpy2
The directory '/Users/ChenGuanYing/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/ChenGuanYing/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting rpy2
  Downloading rpy2-2.7.8.tar.gz (178kB)
    100% |████████████████████████████████| 184kB 1.1MB/s 
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no command (R) in the PATH.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-OtKzsd/rpy2/

enter image description here

最佳答案

错误消息中建议的两种可能的解决方案:

  1. 导出 R_HOME=
  2. 将 R 命令放入系统路径

关于python - 无法在 MAC OS 中通过 pip 安装 rpy2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36107119/

相关文章:

python - 循环遍历一个数据框中的单个列与另一个数据框中的列进行比较使用 Pandas 在第一个数据框中创建新列

r - 你可以通过 do.call 使用 fix 吗?

r - 使用合并语句时出现重复列

python - 使用lxml删除整个节点

python - 如何根据python中的不同条件动态创建列表?

r - 如何将按组绘图元素叠加到 ggplot2 方面?

macos - 在批处理sqlite命令行导入中捕获错误

macos - 安装 zeromq MacOSX 时出现问题

Java Mac appbundle 资源路径

python - 制作一个包含 3 个 python 代码的脚本