A Data Scientist’s guide to run Python in RStudio

2022 Python IDE for Data Science

Wait, what?? Why would you use R Studio as an IDE for running Python? There’s a simple answer to this question: this is the perfect Data Science IDE when you use R and Python together.

You’ll find below the simple steps to help set up a project in R Studio so you can start using Python:

Create an R Studio Project:

Navigate and save your project: File -> New Project – > Existing Directory (linked to the GitHub folder if applicable) / New Directory ( if you work locally) .


Create and activate Python virtual environment

Each project might require different versions of packages and this can be encapsulated in a virtual environment. You’ll have to create and select the virtual environment as the Python interpreter for the RStudio Project and then activate.

  • Install virtual environment with pip install in the RStudio terminal window (initial setup):

pip install virtualenv

  • Create the virtual environment for the current project (initial setup):

virtualenv environment_name

  • Activate the virtual environment for the current project (initial setup):
    • on Windows:


    • on MAC:

source environment_name\bin\activate

Select Python interpreter

Navigate and select your Python interpreter : Tools -> Global Options – > Python -> Select -> Virtual environments

When you open the project, just remember to activate the environment:



(Note: I participate in the affiliate amazon program. This post may contain affiliate links from Amazon or other publishers I trust (at no extra cost to you). I may receive a small commission when you buy using my links, this helps to keep the blog alive! See disclosure for details.)


If you’re new to RStudio , you can browse this book.

Once you start coding, you might be also interested in reading:



This is a personal blog. My opinion on what I share with you is that “All models are wrong, but some are useful”. Improve the accuracy of any model I present and make it useful!

Any comments are welcome

Share this post

Related articles

Cristina Gurguta

content creator

Welcome to www.thebabydatascientist.com! I’m Cristina, a Senior Machine Learning Operations Lead and a proud mom of two amazing daughters. Here, we help nurture your data science career and offer insane data-driven designs for shopping. Join us on this exciting journey of balancing work and family in a data-driven world!

Cristina Gurguta

My personal favourites