David Y.
—How do I install a specific, older version of a Python package using PIP? Will it matter if I have another version already installed?
We can install an older version of a specific package by using the following syntax in our PIP command:
pip install requests==2.30.0
The ==
syntax allows us to specify a version number. We can see which version numbers are available by looking at the release history on the package’s page on PyPI.org.
Note that, on Windows, the package name and version should be surrounded by quotation marks:
pip install "requests==2.30.0"
If a newer version of the package is already installed on our system or in our current virtual environment, we will need to add the --force-reinstall
flag to uninstall that version first:
pip install --force-reinstall requests==2.30.0
To ensure that future users of our project install the correct package versions when setting it up, we should create a requirements file. This is a file in our project’s root directory named requirements.txt
, which contains a list of requirement specifiers (i.e. package names and versions) on which our project depends. For this example, our requirements file would have one line:
requests==2.30.0
We would then be able to install the correct version of this and any other packages added by running the following PIP command:
pip install -r requirements.txt
Again, we may need to provide the --force-reinstall
flag when running this command.
To avoid changing the packages on our entire system for individual Python projects, we can use a virtual environment. This is the recommended way to deal with Python dependencies in most circumstances.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.