FLOSS Project Planets

Real Python: Python's Requests Library (Guide)

Planet Python - Wed, 2024-02-28 09:00

The Requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.

Throughout this tutorial, you’ll see some of the most useful features that Requests has to offer as well as ways to customize and optimize those features for different situations that you may come across. You’ll also learn how to use Requests in an efficient way as well as how to prevent requests to external services from slowing down your application.

In this tutorial, you’ll learn how to:

  • Make requests using the most common HTTP methods
  • Customize your requests’ headers and data using the query string and message body
  • Inspect data from your requests and responses
  • Make authenticated requests
  • Configure your requests to help prevent your application from backing up or slowing down

For the best experience working through this tutorial, you should have basic general knowledge of HTTP. That said, you still may be able to follow along fine without it.

In the upcoming sections, you’ll see how you can install and use requests in your application. If you want to play with the code examples that you’ll see in this tutorial, as well as some additional ones, then you can download the code examples and work with them locally:

Get Your Code: Click here to download the free sample code that shows you how to use Python’s Requests library.

Take the Quiz: Test your knowledge with our interactive “HTTP Requests With the "requests" Library” quiz. Upon completion you will receive a score so you can track your learning progress over time:

Take the Quiz »

Getting Started With Python’s Requests Library

Even though the Requests library is a common staple for many Python developers, it’s not included in Python’s standard library. There are good reasons for that decision, primarily that the library can continue to evolve more freely as a self-standing project.

Note: Requests doesn’t support asynchronous HTTP requests directly. If you need async support in your program, you should try out AIOHTTP or HTTPX. The latter library is broadly compatible with Requests’ syntax.

Because Requests is a third-party library, you need to install it before you can use it in your code. As a good practice, you should install external packages into a virtual environment, but you may choose to install requests into your global environment if you’re planning to use it across multiple projects.

Whether you’re working in a virtual environment or not, you’ll need to install requests:

Shell $ python -m pip install requests Copied!

Once pip has finished installing requests, you can use it in your application. Importing requests looks like this:

Python import requests Copied!

Now that you’re all set up, it’s time to begin your journey through Requests. Your first goal will be learning how to make a GET request.

The GET Request

HTTP methods, such as GET and POST, determine which action you’re trying to perform when making an HTTP request. Besides GET and POST, there are several other common methods that you’ll use later in this tutorial.

One of the most common HTTP methods is GET. The GET method indicates that you’re trying to get or retrieve data from a specified resource. To make a GET request using Requests, you can invoke requests.get().

To test this out, you can make a GET request to GitHub’s REST API by calling get() with the following URL:

Python >>> import requests >>> requests.get("https://api.github.com") <Response [200]> Copied!

Congratulations! You’ve made your first request. Now you’ll dive a little deeper into the response of that request.

The Response

A Response is a powerful object for inspecting the results of the request. Make that same request again, but this time store the return value in a variable so that you can get a closer look at its attributes and behaviors:

Read the full article at https://realpython.com/python-requests/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

PyCon: PyCon US 2024 Schedule Launch. Introducing our Keynote Speakers

Planet Python - Wed, 2024-02-28 06:44

We’re excited to announce the full schedule for PyCon US 2024!

This year, we received a record number of proposals that our Program Committee had to go through: 990 proposals! As a comparison, last year we received a little more than 700 proposals, so it’s almost 40% more proposals compared to the previous year! Thank you to everyone who submitted their proposals.

 
With these many proposals received, we could easily have enough speakers to fill the program for multiple Python conferences! Our volunteer Program Committee has worked hard to select only 14% among the many strong proposals to create an excellent conference program covering a wide range of subjects for attendees to enjoy. We’re looking forward to meeting all the presenters and learning from them at PyCon US 2024.

Meet Our Keynote SpeakersWe are thrilled to announce our Keynote speakers. Please welcome Jay Miller, Kate Chapman, Simon Willison, and Sumana Harihareswara who will be sharing their insights and perspectives on our main conference days, May 17 - May 19, 2024.

Head to the Keynotes page to learn more about the amazing names that make up this year’s Keynote lineup!


Full Schedule ReleasedCheck our updated schedule page to learn more. The schedule has been updated with dates and timing of our Tutorials, Talk Tracks, Charlas Track, and Sponsor Presentations.

Posters will be featured and displayed during all open hours of the Expo Hall and alongside presentations by the authors on Sunday, May 19, 2024. All together, there will be a wide array of topics that we hope experienced and newer Python users will find engaging.

Many thanks to all of those who submitted proposals this year! The schedule would not be the same without all your hard work.
Note that if you’ve attended PyCon US before, you might notice that our scheduling looks slightly different this year. We encourage you to check the schedule ahead of the conference.
Thank You Committees and Reviewers!Thank you to all of our Program Committee members and proposal reviewers who volunteered their time and hard work! Going through close to one thousand proposals is no easy task. Without their efforts in helping to launch the PyCon US Call for Proposals, this would not have been possible.

Their commitment to managing the process of preparing for CFPs to launch and managing the review process began over 6 months ago. We truly could not have accomplished the final result of launching the schedule today without each of them.
  • Tutorial Committee: Sarah Kuchinsky, Merilys Huhn, Mridul Seth, Mfon Eti-mfon
  • Program Committee: Philippe Gagnon, Tereza Iofciu
  • Charlas Committee: Denny Perez, Cristián Maureira-Fredes, Adolfo Fitoria, Aldo Caneo, Andres Pineda, Arturo Martínez Pacheco, Carlos Maldonado, Daniel Hernández Méndez, Yhonatan Peguero
  • Poster Committee: Kristen McIntyre
In addition, we want to send a huge thank you to the numerous volunteers who reviewed each of the submissions and worked long hours to make sure PyCon US has a great line-up. The conference would not take place without the support and time of these volunteers.
Tutorial, Summit, Sponsor Presentation & Event Registration

Registration is now open for Tutorials, Sponsor Presentations, Summits, Mentored Sprints for Diverse Beginners, and the PyLadies Auction.


Be sure to register for the conference here if you have not already done so. Keep in mind that there are limited spaces available for each of the events listed above, with Tutorials and PyLadies Auction being sold out way ahead of the conference each year. So if you’re planning to attend and participate in any of these, be sure to register early.

NOTE: Please be sure to hit “Check out and Pay” when registering for Tutorials. If you do not complete your invoice and a Tutorial sells out, it will be removed from your cart and you will no longer be able to reserve a spot for that session. Please contact pycon-reg@python.org with any questions.

Categories: FLOSS Project Planets

CKEditor: Drupal and CKEditor: a history of advanced content editing | CKEditor

Planet Drupal - Wed, 2024-02-28 06:30

Ever wondered how Drupal got its rich text editor? For 10+ years, Drupal & CKEditor have worked together to deliver world-class content editing for Drupal users. But the story of this open source collaboration goes back to the early days of Drupal.

Learn the full history of the CKEditor-Drupal integration.

Categories: FLOSS Project Planets

Implicit Imports vs. QML Modules in Qt 6

Planet KDE - Wed, 2024-02-28 03:45

Several versions of Qt have been released since my last treatise on QML modules. Most of it is in fact still very valid advice, but I feel I have to stress a few things that people often misunderstand.

Categories: FLOSS Project Planets

Daniel Lange: Opencollective shutting down

Planet Debian - Wed, 2024-02-28 02:45

Update 28.02.2024 19:45 CET: There is now a blog entry at https://blog.opencollective.com/open-collective-official-statement-ocf-dissolution/ trying to discern the legal entities in the Open Collective ecosystem and recommending potential ways forward.

Gee, there is nothing on their blog yet, but I just [28.02.2023 00:07 CET] received this email from Mike Strode, Program Officer at the Open Collective Foundation:

Dear Daniel Lange,

It is with a heavy heart that I'm writing today to inform you that the Board of Directors of the Open Collective Foundation (OCF) has made the difficult decision to dissolve OCF, effective December 31, 2024.

We are proud of the work we have been able to do together. We have been honored to build community with you and the hundreds of other collectives hosted at the Open Collective Foundation.

What you need to know:

We are beginning a staged dissolution process that will allow our over 600 collectives the time to close or transition their work. Dissolving OCF will take many months, and involves settling all liabilities while spending down all funds in a legally compliant manner.

Our priority is to support our collectives in navigating this change. We want to provide collectives the longest possible runway to wind down or transition their operations while we focus on the many legal and financial tasks associated with dissolving a nonprofit.

March 15 is the last day to accept donations. You will have until September 30 to work with us to develop and implement a plan to spend down the money in your fund. Key dates are included at the bottom of this email.

We know this is going to be difficult, and we will do everything we can to ease the transition for you.

How we will support collectives:

It remains our fiduciary responsibility to safeguard each collective's charitable assets and ensure funds are used solely for specified charitable purposes.

We will be providing assistance and support to you, whether you choose to spend out and close down your collective or continue your work through another 501(c)(3) organization or fiscal sponsor.

Unfortunately, we had to say goodbye to several of our colleagues today as we pare down our core staff to reduce costs. I will be staying on staff to support collectives through this transition, along with Wayne Kleppe, our Finance Administrator.

What led to this decision:

From day one, OCF was committed to experimentation and innovation. We were dedicated to finding new ways to open up the nonprofit space, making it easier for people to raise and access funding so they can do good in their communities.

OCF was created by Open Collective Inc. (OCI), a company formed in 2015 with the goal of "enabling groups to quickly set up a collective, raise funds and manage them transparently." Soon after being founded by OCI, OCF went through a period of rapid growth. We responded to increased demand arising from the COVID-19 pandemic without taking the time to establish the appropriate systems and infrastructure to sustain that growth.

Unfortunately, over the past year, we have learned that Open Collective Foundation's business model is not sustainable with the number of complex services we have offered and the fees we pay to the Open Collective Inc. tech platform.

In late 2023, we made the decision to pause accepting new collectives in order to create space for us to address the issues. Unfortunately, it became clear that it would not be financially feasible to make the necessary corrections, and we determined that OCF is not viable.

What's next:

We know this news will raise questions for many of our collectives. We will be making space for questions and reactions in the coming weeks.

In the meantime, we have developed this FAQ which we will keep updated as more questions come in.

What you need to do next:

  • Review the FAQ
  • Discuss your options within your collective. Your options are:
    • spend down and close out your collective
    • spend down and transfer your collective to another fiscal sponsor, or
    • transfer your collective and funds to another charitable organization.
  • Reply-all to this email with any questions, requests, or to set up a time to talk. Please make sure generalinquiries@opencollective.org is copied on your email.

Dates to know:

  • Last day to accept funds/receive donations: March 15, 2024
  • Last day collectives can have employees: June 30, 2024
  • Last day to spend or transfer funds: September 30, 2024

In Care & Accompaniment,
Mike Strode
Program Officer
Open Collective Foundation

Our mailing address has changed! We are now located at 440 N. Barranca Avenue #3717, Covina, CA 91723, USA

Categories: FLOSS Project Planets

parallel @ Savannah: GNU Parallel 20240222 ('Навальный') released [stable]

GNU Planet! - Tue, 2024-02-27 19:17

GNU Parallel 20240222 ('Навальный') has been released. It is available for download at: lbry://@GnuParallel:4

Quote of the month:
 
  Stop paralyzing start parallelizing
    -- @harshgandhi100@YouTube
 
New in this release:

  • No new functionality
  • Bug fixes and man page updates.

GNU Parallel - For people who live life in the parallel lane.

If you like GNU Parallel record a video testimonial: Say who you are, what you use GNU Parallel for, how it helps you, and what you like most about it. Include a command that uses GNU Parallel if you feel like it.


About GNU Parallel


GNU Parallel is a shell tool for executing jobs in parallel using one or more computers. A job can be a single command or a small script that has to be run for each of the lines in the input. The typical input is a list of files, a list of hosts, a list of users, a list of URLs, or a list of tables. A job can also be a command that reads from a pipe. GNU Parallel can then split the input and pipe it into commands in parallel.

If you use xargs and tee today you will find GNU Parallel very easy to use as GNU Parallel is written to have the same options as xargs. If you write loops in shell, you will find GNU Parallel may be able to replace most of the loops and make them run faster by running several jobs in parallel. GNU Parallel can even replace nested loops.

GNU Parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially. This makes it possible to use output from GNU Parallel as input for other programs.

For example you can run this to convert all jpeg files into png and gif files and have a progress bar:

  parallel --bar convert {1} {1.}.{2} ::: *.jpg ::: png gif

Or you can generate big, medium, and small thumbnails of all jpeg files in sub dirs:

  find . -name '*.jpg' |
    parallel convert -geometry {2} {1} {1//}/thumb{2}_{1/} :::: - ::: 50 100 200

You can find more about GNU Parallel at: http://www.gnu.org/s/parallel/

You can install GNU Parallel in just 10 seconds with:

    $ (wget -O - pi.dk/3 || lynx -source pi.dk/3 || curl pi.dk/3/ || \
       fetch -o - http://pi.dk/3 ) > install.sh
    $ sha1sum install.sh | grep 883c667e01eed62f975ad28b6d50e22a
    12345678 883c667e 01eed62f 975ad28b 6d50e22a
    $ md5sum install.sh | grep cc21b4c943fd03e93ae1ae49e28573c0
    cc21b4c9 43fd03e9 3ae1ae49 e28573c0
    $ sha512sum install.sh | grep ec113b49a54e705f86d51e784ebced224fdff3f52
    79945d9d 250b42a4 2067bb00 99da012e c113b49a 54e705f8 6d51e784 ebced224
    fdff3f52 ca588d64 e75f6033 61bd543f d631f592 2f87ceb2 ab034149 6df84a35
    $ bash install.sh

Watch the intro video on http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

Walk through the tutorial (man parallel_tutorial). Your command line will love you for it.

When using programs that use GNU Parallel to process data for publication please cite:

O. Tange (2018): GNU Parallel 2018, March 2018, https://doi.org/10.5281/zenodo.1146014.

If you like GNU Parallel:

  • Give a demo at your local user group/team/colleagues
  • Post the intro videos on Reddit/Diaspora*/forums/blogs/ Identi.ca/Google+/Twitter/Facebook/Linkedin/mailing lists
  • Get the merchandise https://gnuparallel.threadless.com/designs/gnu-parallel
  • Request or write a review for your favourite blog or magazine
  • Request or build a package for your favourite distribution (if it is not already there)
  • Invite me for your next conference


If you use programs that use GNU Parallel for research:

  • Please cite GNU Parallel in you publications (use --citation)


If GNU Parallel saves you money:



About GNU SQL


GNU sql aims to give a simple, unified interface for accessing databases through all the different databases' command line clients. So far the focus has been on giving a common way to specify login information (protocol, username, password, hostname, and port number), size (database and table size), and running queries.

The database is addressed using a DBURL. If commands are left out you will get that database's interactive shell.

When using GNU SQL for a publication please cite:

O. Tange (2011): GNU SQL - A Command Line Tool for Accessing Different Databases Using DBURLs, ;login: The USENIX Magazine, April 2011:29-32.


About GNU Niceload


GNU niceload slows down a program when the computer load average (or other system activity) is above a certain limit. When the limit is reached the program will be suspended for some time. If the limit is a soft limit the program will be allowed to run for short amounts of time before being suspended again. If the limit is a hard limit the program will only be allowed to run when the system is below the limit.

Categories: FLOSS Project Planets

Quansight Labs Blog: Quansight Labs Annual Report 2023: Building for Ecosystem-wide Impact and Sustainability

Planet Python - Tue, 2024-02-27 19:00
Presenting our 2023 annual report! Read about our open source project and community highlights, initiatives, and work culture.
Categories: FLOSS Project Planets

Seth Michael Larson: Security Developer-in-Residence Weekly Report #31

Planet Python - Tue, 2024-02-27 19:00
Security Developer-in-Residence Weekly Report #31 AboutBlogNewsletterLinks Security Developer-in-Residence Weekly Report #31

Published 2024-02-28 by Seth Larson
Reading time: minutes

Windows CPython SBOMs

I've finished up work for Software Bill-of-Materials for generating Windows CPython artifacts, these PRs are being reviewed by Windows release managers. A few things left to do:

  • Run integration tests for the proposed Azure Pipelines definition.
  • Add small change to upload procedure for Windows artifacts to also upload the new SBOM artifacts.

After Windows is complete the only platform left is macOS which I've asked release managers about the best way to get started for this platform.

Conferences and Talks

I'm locked in for conference season in 2024, I'll be attending the following conferences so if you are too then let me know!

Other items

I'll be taking a break from weekly updates in March because I'll be traveling in early and late March meaning I'll only have ~5 normal work days, so if you're curious why there aren't any weekly updates that will be why. ✈️

That's all for this week! 👋 If you're interested in more you can read last week's report.

Thanks for reading! ♡ Did you find this article helpful and want more content like it? Get notified of new posts by subscribing to the RSS feed or the email newsletter.

This work is licensed under CC BY-SA 4.0

Categories: FLOSS Project Planets

KDE MegaRelease 6

Planet KDE - Tue, 2024-02-27 19:00
Full content here: https://kde.org/announcements/megarelease/6
Categories: FLOSS Project Planets

The Drop Times: An Amalgamation of Open Source Benefits and Proprietary Luxury!

Planet Drupal - Tue, 2024-02-27 17:14
Discover how Jon Stewart is redefining the digital landscape with ZenSource—a game-changing platform fusing open-source flexibility with enterprise-grade capabilities. Uncover insights into the strategic use of Drupal, AI integration, and ultra-secure cloud hosting in revolutionizing customer experience platforms.
Categories: FLOSS Project Planets

Exciting talks, hands-on workshops, and thrilling discussions await you at LibrePlanet 2024

FSF Blogs - Tue, 2024-02-27 15:40
In this blog post, we're sharing with you all the sessions that have been confirmed for LibrePlanet 2024: Cultivating Community.
Categories: FLOSS Project Planets

FSF Blogs: Exciting talks, hands-on workshops, and thrilling discussions await you at LibrePlanet 2024

GNU Planet! - Tue, 2024-02-27 15:39
In this blog post, we're sharing with you all the sessions that have been confirmed for LibrePlanet 2024: Cultivating Community.
Categories: FLOSS Project Planets

PyCoder’s Weekly: Issue #618 (Feb. 27, 2024)

Planet Python - Tue, 2024-02-27 14:30

#618 – FEBRUARY 27, 2024
View in Browser »

McKinney on Improving the Data Stack & Composable Systems

How do you avoid the bottlenecks of data processing systems? Is it possible to build tools that decouple storage and computation? This week on the show, creator of the pandas library Wes McKinney is here to discuss Apache Arrow, composable data systems, and community collaboration.
REAL PYTHON podcast

Introducing Flask-Muck: Building a REST API in 5 Minutes

Flask-Muck sits on top of a Flask/SQLAlchemy tech stack and uses a declarative and modular approach to replace huge amounts of boilerplate code by generating a full-featured set of standard CRUD endpoints for a resource. Learn how to use it by reading this post.
DANNY TIESLING • Shared by Danny Tiesling

Live Hack: Exploiting AI-Generated Code

Join Snyk’s Live Hack Workshop! Get live expert support while learning how to exploit & remediate vulnerabilities. March 6th | 11:00am ET (Worth 1 CPE credit) →
SNYK.IO sponsor

10 Years of Wagtail

Tom Dyson, a founding member of the Wagtail core team, shares some thoughts about how Wagtail CMS grew from a small, niche open source project into one of the most popular Python CMSs used by NASA, Google, the National Health Service, and many others.
TOM DYSON

Astral Takes Stewardship of Rye

ARMIN RONACHER

PySimpleGUI 4 Sunsets in Q2 2024

PYSIMPLEGUI

Discussions uv Another Rust Tool Written to Replace pip

PYTHON DISCUSS

Articles & Tutorials BNF Notation: Dive Deeper Into Python’s Grammar

In this tutorial, you’ll learn about Backus–Naur form notation (BNF), which is typically used for defining the grammar of programming languages. Python uses a variation of BNF, and here, you’ll learn how to read it to get a better understanding of some language constructs.
REAL PYTHON

Thread Local Data in Python

The article introduces the threading module’s local() for storing thread-local values. Since threads in Python share the memory space of their parent process, you might need to define thread-specific variables for specific use cases to avoid unintended side effects.
ADARSH DIVAKARAN • Shared by Adarsh Divakaran

Blocked by Slow Code Reviews? Here’s How to Stop Waiting

Code reviews are great - but they shouldn’t slow down your development. Sourcery can automatically review every one of your PR’s so your team can keep moving fast →
SOURCERY sponsor

Unleashing the Power of the Console With Rich

Rich is a powerful library for creating text-based user interfaces (TUIs) in Python. It enhances code readability by pretty-printing complex data structures and adds visual appeal with colored text, tables, animations, and more.
REAL PYTHON course

Python Monorepo Visualization

Monorepos can be a bit overwhelming, containing all the code for all your projects. Thankfully, there are ways to visualize a Python monorepo. This blog post introduces you to one repo visualizer: Polylith
DAVID VUJIC • Shared by David Vujic

Counting CPU Instructions in Python

Did you know it takes about 17,000 CPU instructions1 to print(“Hello”) in Python? And that it takes ~2 billion of them to import seaborn? Learn about the tools Matt used to find this out.
MATT STUCHLIK

The Broken Version Breakdown

Pypi is a real treasure box full of great Python tools. Unfortunately, released versions of most of them can suddenly be broken by a downstream dependency release.
IVO HOUBRECHTS • Shared by Ivo Houbrechts

Not Just NVIDIA: GPU Programming That Runs Everywhere

This article talks about wgpu-py, a GPU portable Python library. Ever want to use the GPU but use something other than NIVIDIA? This library might be for you.
ITAMAR TURNER-TRAURING

Add Versatility To AI Apps, Build With Popular Model Choices Like YOLOv8

Future-proof your AI apps with constantly expanding model compatibility, including YOLOv8, Padim, and more. Speed up development and deploy seamlessly with Intel’s OpenVINO toolkit.
INTEL CORPORATION sponsor

Floats Are Weird

This post attempts to demonstrate a calculus proof by applying floats, but of course the precision of floats get in the way. See what happens.
EXOZY

Django REST Framework and Vue vs HTMX

Learn how the development process varies between working with Django REST Framework and Vue versus Django and HTMX.
ŠPELA GIACOMELLI • Shared by Michael Herman

Projects & Code temporian: Library for Preprocessing Temporal Data

GITHUB.COM/GOOGLE

mac-cleanup-py: Cleanup Script for macOS in Python

GITHUB.COM/MAC-CLEANUP

lockbox: Forward Proxy for Making 3rd Party API Calls

GITHUB.COM/MKJT2

rexi: Terminal UI for Regex Testing

GITHUB.COM/ROYREZNIK

sqlite-web: Web-Based SQLite Database Browser

GITHUB.COM/COLEIFER

Events Weekly Real Python Office Hours Q&A (Virtual)

February 28, 2024
REALPYTHON.COM

SPb Python Drinkup

February 29, 2024
MEETUP.COM

PyLadies Amsterdam

February 29, 2024
MEETUP.COM

PyCon Namibia 2024

March 4 to March 8, 2024
PYCON.ORG

Melbourne Python Users Group, Australia

March 4, 2024
J.MP

PyCon Pakistan 2024

March 9 to March 11, 2024
PYCON.PK

Happy Pythoning!
This was PyCoder’s Weekly Issue #618.
View in Browser »

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

Categories: FLOSS Project Planets

Kushal Das: Mullvad VPN repository for Fedora

Planet Python - Tue, 2024-02-27 12:37

Mullvad VPN now has proper rpm repository for their desktop client. You can use it in the following way on you Fedora system:

sudo dnf config-manager --add-repo https://repository.mullvad.net/rpm/stable/mullvad.repo sudo dnf install mullvad-vpn

Remember to verify the OpenPGP key Fingerprint:

Importing GPG key 0x66DE8DDF: Userid : "Mullvad (code signing) <admin@mullvad.net>" Fingerprint: A119 8702 FC3E 0A09 A9AE 5B75 D5A1 D4F2 66DE 8DDF From : https://repository.mullvad.net/rpm/mullvad-keyring.asc
Categories: FLOSS Project Planets

Mike Driscoll: uv – Python’s Fastest Package Installer and Resolver

Planet Python - Tue, 2024-02-27 09:09

There’s a new Python package installer out now and it’s called uv. The uv package installer and resolver is made by Astral. Uv is written in Rust instead of Python and is super fast! Astral is best known for Python’s fastest formatter, Ruff. The uv package is meant to be a drop-in replacement for pip and pip-tools. According to Astral, “uv is 8-10x faster than pip and pip-tools without caching, and 80-115x faster when running with a warm cache (e.g., recreating a virtual environment or updating a dependency)”.

Astral is also taking over the development of Rye, an experimental Python packaging tool from Armin Ronacher. From the sounds of Astral’s announcement, Rye and uv will become one tool as the two projects have a shared vision for Python packaging.

Installing uv

You can install uv using Curl:

curl -LsSf https://astral.sh/uv/install.sh | sh

Or you can use pip:

pip install uv

Now that you have uv installed, you can start installing packages!

Using uv

Let’s try running uv in your terminal:

c:\code> uv Usage: uv.exe [OPTIONS] <COMMAND> Commands: pip Resolve and install Python packages venv Create a virtual environment cache Manage the cache help Print this message or the help of the given subcommand(s) Options: -q, --quiet Do not print any output -v, --verbose Use verbose output --color <COLOR> Control colors in output [default: auto] [possible values: auto, always, never] -n, --no-cache Avoid reading from or writing to the cache [env: UV_NO_CACHE=] --cache-dir <CACHE_DIR> Path to the cache directory [env: UV_CACHE_DIR=] -h, --help Print help (see more with '--help') -V, --version Print version

You’ll need to create and activate a Python virtual environment to install packages with uv.

Here’s an example:

C:\code> uv venv test Using Python 3.11.5 interpreter at C:\Users\wheifrd\AppData\Local\Programs\Python\Python311\python.exe Creating virtualenv at: test Activate with: test\Scripts\activate C:\code> .\test\Scripts\activate (test) C:\books>

Now you’re ready to install a Python package. You can use numpy for a test run:

(test) C:\books> uv pip install numpy Resolved 1 package in 615ms Downloaded 1 package in 2.81s Installed 1 package in 332ms + numpy==1.26.4

As you might expect, you can also use uv to install:

  • a list of space-delimited packages
  • a requirements.txt file
  • a pyproject.toml file

If you need to generate a locked requirements.txt file, you can run uv pip compile.

Wrapping Up

Astral hopes to create a “Cargo for Python” with the release of uv. While it’s still early, this project is well worth watching as the Rust package itself is amazingly fast and useful even though it’s only been out for about a year. You can read more about uv in Astral’s blog post.

 

The post uv – Python’s Fastest Package Installer and Resolver appeared first on Mouse Vs Python.

Categories: FLOSS Project Planets

Real Python: Python Basics Exercises: Installing Packages With pip

Planet Python - Tue, 2024-02-27 09:00

So far on the Python Basics learning path, you’ve been working within the bounds of the Python standard library. Now it’s time to unlock packages that aren’t included with Python by default. To do that, you’ll need pip.

Many programming languages offer a package manager that automates the process of installing, upgrading, and removing third-party packages. Python is no exception. The de facto package manager for Python is called pip.

In this Python Basics Exercises course, you’ll test and reinforce your knowledge of installing packages and managing virtual environments.

In this video course, you’ll practice:

  • Installing and managing third-party packages with pip
  • Using virtual environments to separate project dependencies
  • Declaring requirements and re-create a development environment

By the end of this course, you’ll have an even stronger grasp of installing packages to suit your programming needs

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. Note that you’ll be using IDLE to interact with Python throughout this course.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Pages