How to write my add-on so that when installed it also installs dependencies (let's say: scipy or numpy-quaternion)?
Does blender understand setuptools (setup.py)?
Thanks,
Note: I'm using blender 2.8
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityRan into the same issue and received helpful responses on devtalk. There's also another post that was helpful when installing pip for 2.81.
2.81
import subprocess
import bpy
py_exec = bpy.app.binary_path_python
# ensure pip is installed & update
subprocess.call([str(py_exec), "-m", "ensurepip", "--user"])
subprocess.call([str(py_exec), "-m", "pip", "install", "--upgrade", "pip"])
# install dependencies using pip
# dependencies such as 'numpy' could be added to the end of this command's list
subprocess.call([str(py_exec),"-m", "pip", "install", "--user", "scipy"])
Modification for 3.6
import sys
py_exec = sys.executable
Warnings:
One possible solution is to keep add-on and dependencies installation separate, i.e:
First install deps into Blender's python:
path/to/blender/python -m ensurepip
and path/to/blender/python -m pip install -U pip
pip install <whatever need be>
And then install the add-on.
This is not an elegant solution though, having to tell your users to go through this process is not convenient.