image: thumbnail.jpg
How to Install a Python Package with pip in Positron (Your First Library in 2 Minutes)
What you will learn
- Why installing a library is normally the first thing you do in a new project
- Where to find the terminal in Positron
- How to run pip install, and what happens while it runs
- What dependencies are, and why pip fetches them for you
- What the Python Package Index is
- How pip freeze lists what you have, with versions
- What requirements.txt is for, and why you will see it in every Python project
Chapters
0:00 Why your first step is installing a library
0:18 Opening the terminal and running pip install
0:36 What pip does: dependencies and the Python Package Index
0:54 pip freeze: seeing what is installed
1:12 requirements.txt, and reproducing your environment
Learn more
Positron: https://positron.posit.co
Installing Python packages in Positron: https://positron.posit.co/interpreters.html
Posit Package Manager: https://posit.co/products/enterprise/package-manager/
PyDyTuesday, the library used here: https://pypi.org/project/pydytuesday/
Transcript#
This transcript was generated automatically and may contain errors.
Once your Python project is set up, you're probably eager to start coding. But what do you write? Often, the first step will be to download some Python libraries.
Take the PyTuesday project, for example. They've created a handy library that makes grabbing those weekly datasets an absolute breeze. So let's show you how to install the PyTuesday library right now.
Installing with pip in Positron
First, we'll head over to the terminal tab in Positron. We'll use Pip, Python's go-to package manager, to handle the installation. In the terminal, you'll simply type pip install PyTuesday. As soon as you hit enter, Pip gets to work, automatically downloading the library and any other dependencies it needs.
Think of it like this. Just as you download a book from an online store, we're downloading the PyTuesday library from a vast online collection of Python libraries called the Python Package Index, or PyPI.
Just as you download a book from an online store, we're downloading the PyTuesday library from a vast online collection of Python libraries called the Python Package Index, or PyPI.
Managing installed packages
If you ever want to see which packages are currently installed in your environment, just type pip freeze in the terminal. This command lists every library along with its version number. This output is incredibly useful for reproducing your project's environment, which is why you'll often see the output of this command saved to a file called requirements.txt.