简体   繁体   English

无法使用 reticulate 更改用于与 R 交互的 Python

[英]Unable to change the Python to be used for interacting with R using reticulate

I want to use a specific Python version: /Users/aviral.s/.pyenv/versions/3.5.2/bin/python .我想使用特定的 Python 版本: /Users/aviral.s/.pyenv/versions/3.5.2/bin/python This version is not available for R.此版本不适用于 R。

I tried reading the documentation but following all the three steps(setting the env variable, using the API use_python() didn't help either.我尝试阅读文档,但遵循所有三个步骤(设置 env 变量,使用 API use_python()也无济于事。

With sudo , I run the following code:使用sudo ,我运行以下代码:

library("reticulate")
py_config()
use_python("/Users/aviral.s/.pyenv/versions/3.5.2/bin/python")
py_config() # Unchanged.

I tried using any of the available ones in the py_config() which worked by setting the environment variable as in here我试图在py_config(),它通过工作设置环境变量在使用任何可用选项的位置

However, if I set the same env variable to my pyenv version, I get this error:但是,如果我将相同的 env 变量设置为pyenv版本, pyenv此错误:

> library("reticulate")
> py_config()
Error in initialize_python(required_module, use_environment) :
  Python shared library not found, Python bindings not loaded.

My env variable is correct:我的环境变量是正确的:

echo $RETICULATE_PYTHON
/Users/aviral.s/.pyenv/versions/3.5.2/bin/python

I ran into the same problem a few days ago and i had to jump through all kinds of hoops to get where i wanted and i am not sure which one did it for me, but what definitely helped was using py_discover_config() instead of the regular py_config() command.几天前我遇到了同样的问题,我不得不跳过各种各样的圈子才能到达我想要的地方,我不确定哪个为我做了,但肯定有帮助的是使用py_discover_config()而不是常规的py_config()命令。

what might be another problem, is that apparently a python version with installed numpy will always be preferred by reticulate:另一个问题可能是,显然安装了 numpy 的 python 版本总是被 reticulate 首选:

蟒蛇信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM