我知道对此已经有很多说法,但是我仍然想知道为什么这对我不起作用。
> library(reticulate)
> use_python('/usr/local/bin/python3', required = T)
> py_config()
python: /usr/local/bin/python3
libpython:
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config-
3.5m/libpython3.5.dylib
pythonhome: /Library/Frameworks/Python.framework/Versions/3.5:/Library/Frameworks/Python.framework/Versions/3.5
version: 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
numpy: [NOT FOUND]
NOTE: Python version was forced by use_python function
> reticulate::repl_python()
Python 3.5.2 (/usr/local/bin/python3)
Reticulate 1.12 REPL -- A Python interpreter in R.
>>> import pandas as pd
ImportError: No module named 'pandas'
>>>
但是,当我从jupyter笔记本或命令行运行时,此方法有效 我的R版本是
> R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) > 2019 The R Foundation for Statistical Computing > Platform: x86_64-apple-darwin15.6.0 (64-bit)