【发布时间】:2019-10-02 20:36:49
【问题描述】:
我知道以前有人问过类似的问题,但我要么不明白答案,要么没有答案;所以我决定尽可能详细地描述我的问题。
问题: RStudio reticulate 包使用此路径中的 Python:
"/usr/bin/python"
但我希望它从此路径中使用 python - 始终作为默认值:
"/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"
我怎么知道它发生了? 我打开 RStudio,并创建一个新的 python 脚本。生成一个扩展名为 .py 的新文件。我输入一些内容:
import pandas as pd
并执行(通过单击 cmd+enter)。然后我看到控制台中发生了什么 - 调用了 reticulate 包:
reticulate::repl_python()
Python 2.7.10 (/usr/bin/python)
Reticulate 1.12 REPL -- A Python interpreter in R.
我想永久更改 reticulate 包查找 Python 的位置。 从我知道的终端:
$ python --version
Python 3.7.3
which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
所以,我想告诉 RStudio 始终在这条路径中查找 Python 3.7。我尝试使用以下命令,从 R 脚本运行:
use_python("/Library/Frameworks/Python.framework/Versions/3.7/bin/python3")
但它没有做任何事情——我天真的理解是这个命令在 R 降价文件中很有用,即当我有将 R 和 Python 组合在单独块中的代码时。我想更改从 RStudio 中运行 Python 脚本时使用的路径。有什么我可以编辑的配置文件吗?
我希望这是有道理的。我不是普通的 Python 用户,现在才开始学习,而且我对路径也不是很好,所以我会很感激一步一步的回答。
【问题讨论】:
-
我发现这个问题正在寻找一种将 R system() 命令使用的 python 版本更改为终端中使用的版本的方法。为此,这两个问题提供了解决方案:stackoverflow.com/questions/36705878/…、stackoverflow.com/questions/14617041/…。
标签: python r python-3.x rstudio