Package installation
In this first section, we will install the packages needed for this course.
Python packages
Python can do a lot out of the box, but for specialized tasks, you need to install additional packages. Packages contain additional functions and variables. Some packages also contain data.
You can find Python packages in the Python Package Index (PyPI)—a repository of open source packages.
To know which packages to use, you can talk with colleagues or look at the literature to see what people in your community use.
Package managers
There are many ways to install Python packages.
For instance, people who need to use the Digital Research Alliance of Canada supercomputers have to use pip: the package installer for Python. This is the most lean and efficient fashion to manage Python packages.
An alternative to pip is conda: a package and environment manager for Python and other languages.
Finally, the most convenient (but also the most bloated) option is to use Anaconda. This is what you have been using so far, so we will stick to the same workflow.
Anaconda is a big project that comes with Python and a suite of packages needed for science. It also provides conda, as well as a graphical interface to manage your environments and packages. It makes things very easy for you, but it is also a very big and will take time to install and use up a lot of space.
The getting started with Navigator page of the Anaconda documentation goes over the steps necessary to create a new Python environment and install packages.
First, launch the Navigator.
Python environments
Why do we need to create a Python environment?
There are a very large number of Python packages and some might conflict with each other. They may also have conflicting dependency requirements.
For instance, package A might need package B at version 3.4 (package B is called a dependency of package A—it is not a package you install explicitly, but it needs to be installed before package A can work), while package C requires package B at version 2.8. Dependencies get automatically installed when you install packages, but if you want to use package A and C together, you run into conflicts. Having different environments for different projects allows to only have the few packages that you need for each project in each environment and makes the whole situation a lot simpler.
Following the Anaconda documentation, let’s create a new environment called text
and activate it.
Installing packages
Now, we can install packages in our environment, still using the Anaconda Navigator.
The packages you need for this course are:
- textblob
- requests
- pymupdf
Following the Anaconda instructions, look for, then install each of these packages.
You are now ready for this course.