Why does Rstudio console not run the python script the way other IDEs like Spyder or Jupyter notebook does?

Viewed 25

I am trying to run a chunk of python code in Rstudio using the reticulate package. Be it a standard python script or RMarkdown, the Rstudio console shoots through the code and does not stop to ask me for input whenever it runs an input command. Here's an example:

print('How much do you think Zuck owns?')

Zuck = int(input("Enter Zuck's net worth: "))

if Zuck < 5000000000:
    print("That ain't much!")
elif Zuck == 5000000000:
    print("That's 5 billion!")
else:
    print("Ima make more after I graduate")

If I were running this code in Spyder/Jupyter notebook, the code will stop at the input command and ask me to enter Zuck's net worth before proceeding. Instead, here's what it does in Rstudio:

Rstudio screenshot: Python script at the top, console at the bottom

It is not stopping at the input command for me to enter Zuck's net worth. It rather goes ahead with the if statement, without assigning any value to the input - thus generating an error.

The same problem happens even in RMarkdown python code chunk.

Please let me know if there is any way for this to work.

0 Answers
Related