无法更改网状(R)中的python路径 [英] Unable to change python path in reticulate (R)
问题描述
启动rstudio会话时,我运行的第一行是:
The first lines I run when launching my rstudio session are:
library(reticulate)
use_python("/usr/local/lib/python3.6/site-packages")
但是,当我运行py_config()
时,它显示仍在使用默认的python 2.7安装.
However, when I run py_config()
it shows as still using the default python 2.7 installation.
这是一个问题b.c我无法导入为python3安装的任何模块.知道为什么这行不通吗?我相当仔细地遵循了文档.
This is an issue b.c I'm unable to import any modules that were installed for python3. Any idea why this isn't working? I followed documentation fairly closely.
推荐答案
我发现.RProfile中的"use_python('path')"技术和Sys.setenv(RETICULATE_PYTHON ='path')的策略都不适用于我(当然,我确信它一定对其他人有用.)
I observed that neither the technique "use_python('path')" nor the tactic of Sys.setenv(RETICULATE_PYTHON = 'path') in .RProfile worked for me (of course I am sure it must have worked for others.)
在任何情况下,终端上的行
In any case the line at terminal,
which -a python python3
产生了两个可供选择的路径(一个用于在我的mac上安装的python2,一个用于安装在我的mac上的python3),因此我能够在主目录中创建一个".Renviron"文件,其中只有以下一行:>
did produce two paths to choose from (one for python2 and one for python3 installed on my mac), so then I was able to create a ".Renviron" file in my home directory with this single line in it:
RETICULATE_PYTHON="/usr/local/bin/python3"
重新启动RStudio后,library(reticulate)
激活所需的python3,然后repl_python()
打开python3交互式窗口,等等.
After I restarted RStudio, library(reticulate)
activates the desired python3, and repl_python()
opens a python3 interactive window, etc. etc.
这篇关于无法更改网状(R)中的python路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!