

I’ll start with APT because most modules can be installed with it, then I’ll introduce PIP and will conclude with a few tips on how to manage your Python libraries.īy the way, if you get overwhelmed as soon as Python is required for a project, I recommend checking out my e-book “ Master Python on Raspberry Pi“. Another tool named “PIP” can also be used for some other modules not included in the default repositories.Įither way, I’ll explain everything in this article. Searching for the library name with this tool will be the fastest way to install them. Most of the Python packages for Raspberry Pi are available in the APT repositories. Even if you are good with Python, you might need some help knowing how to install new packages for Python on Raspberry Pi, which is exactly why I wrote this article. The import statement should be one of the first lines in your code.Python is already installed on Raspberry Pi, but using it to create scripts and build various projects will often require some dependencies named libraries or modules. To do so, you need to include the line “import ”, for example, “import md5utils”. To be able to use a downloaded module in python you need to import the module into your code. Use the command “pip3 install ” to install a specifically named package. For example, the command “pip3 install md5utils” will install the “md5utils” module in python3.

Use the command “pip3 search ” to search for a package to install.To install a module you’ve found, type the command “pip3 install ” and pip will automatically collect and install the files you need. The package name is on the left, with a short description listed on the right. For example, you can type “pip3 search md5” to search for modules relating to the md5 hashing algorithm. To do so you need to use the search function with the command “pip3 search ”. The first step of installing a package with PIP is to work out what the package is called. The PIP and PIP3 commands are interchangeable.

You don’t necessarily need both, but they can only affect packages for their respective python environments. Note: Python 2.7 and Python 3 have different versions of PIP.
