Skip to main content

The PreTeXt Guide

Section C.3 PIP Install

PIP, in the open source tradition of recursive acronyms, stands for “PIP Installs Packages”. This package manager helps you obtain software and keep it up-to-date. There are three packages that are indispensable for use with PreTeXt so you can practice doing installations now via your virtual environment.
If you have installed the PreTeXt-CLI already using pip, then all the programs below are already installed. Otherwise (for example, if you are using xsltproc) you will need to install the following manually.
To install all required additional python libraries, in your virtual enviroment, navigate to the pretext directory and run
(ptx) $ pip install
You can also install individual libraries, as in
(ptx) $ pip install lxml
With lxml, you have a collection of Python routines that interface with the same base libraries for XSL processing as the xsltproc executable. A second library is requests which moderates communications with online servers and is necessary to communicate with WeBWorK servers and with a YouTube server that provides thumbnail images for static versions of videos. The pdfCropMargins package provides a tool that will crop images during their production with the pretext script. The pyMuPDF library then converts the PDF that was cropped to SVG and PNG images. Finally, playwright uses a Chromium headless browser to take static screenshots of interactive elements of your project.
Note that right after you install playwright then you want to run
 playwright install
one time only. This will install three web browsers (Chromium, Firefox, WebKit) and FFMPEG where they should only be available to this package.
Table C.3.1. PIP-installable Python Packages
Package Purpose
lxml
XSL processing
requests
Communication with online servers
pdfCropMargins
Crop images during production
playwright
Automatic screenshots of interactive elements
pyMuPDF
Convert images to SVG and PNG