Cannot get Python chunks to run at once (RStudio runs line by line)


I made a post about this on Stackexchange but no one answered.

I'm trying to start using Python and want to use the RStudio IDE as it's what I'm used to.

I cannot seem to get .Rmd code chucks to run all at once, Rmds just run each line one after another. This isn't the case when I click "run current chunk"

Consider a basic loop I found online :

fruits = ["apple", "banana", "cherry"]
for x in fruits:

This is what I get when I try to run pressing CTRL+Enter (in R, if I were to make a loop, function, or use magrittr, the entirely of the "chunk"/code block would just run)

Basically, if I run one line, I get those ellipses and it doesn't continue to the end of the for statement.

Whereas when I press "run current chunk" twice, it behaves normally. (2nd part of the screenshot I'm uploading

Any ideas as to what could be causing this? Ideally, I could just run Python code as I would do in R to make nice markdown files.

Meant to post multiple photos but I can't as this is my first topic on here. Thank you for your help!

Unfortunately RStudio doesn't have this feature. You can request it by commenting/upvoting here:

However, a good workaround for now might be to have RStudio run code by "paragraphs" instead of statements (look under Options > Code > Execution). This will keep RStudio from having to understand the code to find statement boundaries; it will just run everything between blank lines, which might work for your purposes.

Ah okay thanks for the response! Was really scratching my head on this one. Off topic, but are there other IDEs that do this? I really haven't used much of anything outside of R and Stata, and thus it's really weird to me that this isn't base functionality. Not to be too critical because it's great that you can integrate Python code in Rmds, but it really slows down the workflow. I'll go share my thoughts there.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.