How to install required packages to the Blender Python with pip

For add-ons developing, sometimes it is necessary to use packages that are not included in the core set of the Blender Python interpreter. Most often, the dependencies you need are included in the Python Package Index (PyPI) and can be installed to Blender through the Pip package management system.

The Pip Package Manager is already installed in Blender. However, Blender does not allow us to install the desired packages in a common way with the “pip install package_name” command.

To install the necessary package to Blender using Pip, we need to perform the following:

Start Blender, open the “Text Editor” window and press the “New” button to create a new script.

First, we need to get the full path to the python.exe executable for the current Blender Python interpreter.

Let’s perform all the next actions in a subprocess not to slow down the Blender itself.

At first, it is always recommended to check the installation of the pip module and update it to the latest version.

After pip is updated we can install the necessary dependencies.

The following command will install the desired package to the Blender Python. Replace the “package_name” with the name of the desired package.

The final code:

After executing the script by clicking the “Run Script” button, the specified package will be installed to the Blender Python interpreter.

Note that for correct installation, active Internet access is required. You may also need to run Blender with administrator privileges.

Nikita

Author: Nikita

Blender add-ons developer and articles writer.