Cannot Run Python Scripts in RStudio IDE in Mac (Python - Homebrew)

I'm trying to run this code to test RStudio IDE with Python. I followed this post as a reference: GitHub - rstudio/reticulate: R Interface to Python.

I'm using a python version 3.7 installed using the Homebrew in my MAC. As I specified, the paths and virtual environment, there was not necessary to install miniconda, as described in the reference post, but the error message suggested that we need to install miniconda to use Python in RStudio.

This is the code used to test.

import pandas as pd
data = {'Email': ['','','], 
  'address': ['Street a','Van Street 123','Rue knkn'],
  'company_name': ['ABC','A123','HelloA'], 
  'customer_id': [7,8,9], 
  'no': [10,11,12]}

df = pd.DataFrame(data)      

I'm receiving errors as following:

Using as RMarkdown


And inserting python file using SOURCE

Thank you,

Using Python installed via Homebrew on my Mac, I was able to get reticulate working by defining the following in my ~/.Rprofile :

Sys.setenv(RETICULATE_PYTHON = "/usr/local/bin/python3")

... or you can point that to a python binary in a virtualenv created from the homebrew Python installation.

Then you can remove all of the reticulate::use_* functions from your R code since reticulate will pick up that env var.

We generally see more consistent behavior when users configure the RETICULATE_PYTHON environment variable as described on, or in our best practices described at:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.