Interactively running Python script in R Studio - how to install a package?

240 Views Asked by At

I installed reticulate package. I created Python script in R-Studio

import os
import pandas as pd

Running first line bring Python console >>> and runs fine. The second line generates ModuleNotFoundError: No module named 'pandas'.So I am guessing I need to install pandas (or maybe activate environment, since miniconda is installed) I tried the following in Terminal of R-Studio:

pip
pip3
conda

All of them returned: bash: <relavant_command> command not found...

How can execute this line import pandas as pd

1

There are 1 best solutions below

0
On

You can use the function py_install from reticulate.

https://rstudio.github.io/reticulate/reference/py_install.html