Resources

Your First Python Project in Positron

video
Oct 28, 2025
7:08

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Hi, I'm Sarah Altman, a Data Science Educator at Posit. In this video, I'll show you how to create your first Python project in Positron. I'll walk through the process of opening a folder, setting up a virtual environment, creating a Quarto document, versioning with Git, and deploying Deposit Connect.

Setting up the project folder

First, make sure you've downloaded Positron and have a supported Python interpreter installed. Let's create our project. The first step is to open a folder. This will create a workspace for our project. I'll choose New Folder and then Python Project, and then pick a name for the folder. I'm going to call it First Python Project and select a location by clicking Browse.

And then I'm going to check Initialize Git Repository to set up version control for the project. If you don't plan on using Git, you can skip this step.

Creating a virtual environment

Next, I'm going to set up the virtual environment. Make sure Create a New Virtual Environment is selected and then select a way to create the virtual environment. You can either use Venv, UV, or Conda if you have UV and Conda installed. I'm going to use Venv. Then finally, select a Python interpreter. This is the version of Python that you want to use in your project. And click Create.

Now, Positron has opened our new folder. You can see the files that it created over here in the File Explorer on the left-hand side. Positron also created and activated that virtual environment. This means that much of the setup for our Python project is already done.

Installing libraries

Now that the virtual environment is active, we can install the libraries that we'll need for our project. We're going to open the terminal, and then install Jupyter, Pandas, and Matplotlib. We'll need Jupyter to render Quarto documents.

Next, I'll capture the environment in a requirements.txt file so it's reproducible. Positron can recognize requirements.txt files in a project and can prompt the user to install libraries from the file, which makes it easy for others to recreate the same environment.

Creating a Quarto document

Now that our environment is ready, we can start adding files and running Python code. I'm going to do my work in a Quarto document. I'll first pull up the Command Palette with Command-Shift-P. You can access all of Positron's commands from the Command Palette. And then I'm going to search for Quarto new document.

Now I have a new blank Quarto document. So let's load some data and take a look at it. First, I'll insert a new Python cell into the Quarto doc. And now I'm going to read in some weekly US gasoline prices data from Tidy Tuesday.

This code imports some libraries and then reads the data in from a URL. After running this code, notice that df and the other variables we created show up in the Variables pane over on the right-hand side. I can click this spreadsheet icon next to df to launch the Data Explorer, a spreadsheet-style view where you can sort, filter, and view summary statistics for your data, all without writing any additional code.

Now let's visualize the data. So let's run that code. Now you'll notice that the plot shows up over in the Plots pane on the right.

So this is a pretty short analysis, but it's a good starting point. And now we can render our Quarto document to see what it looks like. First, I'm going to give it a title and save the file. And now I can click Preview to render. The rendered result opens in the Viewer pane on the right.

Committing and pushing to GitHub

Next, I'm going to commit and push my changes to GitHub. This is the source control view where you can stage changes, commit, and push changes to GitHub. Click the plus next to a file to stage the changes. I'm going to add the Quarto document, the gitignore file, readme, and the requirements file for now. Then I'm going to add a commit message to this message text box and click Commit.

Next, I'm going to click this little cloud icon to publish the branch. This is going to create a corresponding remote repository on GitHub and then push the changes. So let's make a public repo. Just need to name it something else. And now Positron will create that repository and push my changes. So let's open it on GitHub. OK, here it is.

Deploying to Posit Connect

The final step is to set up a deployment deposit connect so I can share my report with others. If you have access to PositConnect, you can use Posit Publisher from Positron to deploy your work to Connect. If you don't have access to PositConnect, PositConnect Cloud provides an easy way to publish quarter reports, shiny apps, and more from GitHub for free.

So this is the Posit Publisher view. And I'm going to use this to create a new deployment. I click here. And then I want to deploy this gathprices.qnd file, add a name, and then select where I want to deploy it to. And then I just need to click this Deploy Your Project button, and Positron will deploy my content. OK, here's the file deployed to PositConnect.

If you've been following along, you now have a basic working Python project set up in Positron, the virtual environment, version control, and it's deployment ready to go. To learn more, take a look at the corresponding blog post and the links in the description. And that's it for this video. If you have any questions, please feel free to reach out to me on Twitter, Instagram, or LinkedIn. And I'll see you in the next video. Bye.