Installing Python packages with pip in Blender on Windows 10

We can install additional python module packages to Blender, which are not installed by default, with pip. However, if we use Windows 10, the python interpreter installs new packages not into the Blender installation directory, but into the personal user directory.

During installation, pip will show the following warning in the system console:

Defaulting to user installation because normal site-packages is not writeable

The packages will be installed, but into the directory:

c:\Users\_windows_user_name_\AppData\Roaming\Python\Python39\site-packages\

As a result, packages are installed but are not available inside Blender – they cannot be accessed from the Python console or Blender Text Editor using the “import” command.

We can solve the problem by hard-coding the directory where pip should install the required packages – the “site-packages” directory located inside the directory where Blender is installed.

Let’s define 2 variables – in the first, we will set the path to the executable Blender python.exe file, in the second – the path where the packages would be installed.

First, upgrade pip:

And install the required package, specifying the destination directory:

Full code:

Now, the packages will be installed correctly, in a directory inside Blender, and can be used in it.


*.blend файл with code for my Patreon subscribers

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comment
Inline Feedbacks
View all comments