Allow easy pip modules setup
- Global python site packages folder is likely to be read only
- Break your software by setting up dependency, overriding stock modules
- System may not be able to build modules
- Setup into user site package
- Never install deps (you have to handle your deps by hand)
- Only download and install from wheels
By default Pip class use -user --only-binary all --no-deps
options to call pip.
Pip.install("scipy==1.2.1")
Pip.uninstall("pyproj==2.1.3")
Pip.upgrade_pip()
You have to check for your modules dependency, and setup by hand according your needs.
Also ensure there are wheels available for all target platforms.
python_version = Pip.python_version()
if python_version.minor == 6:
see https://pip.pypa.io/en/stable/reference/pip_install/
Pip.install("scipy==1.2.1")
Pip.install("pyproj==2.1.3")
Pip.install("Pillow==6.0.0")
# Sample usage in a blender operator
def execute(self, context):
# Pyside2 require shiboken
# override default options to skip --no-deps
# we may setup both by hand instead
res, msg = Pip.install("pyside2", "--user --only-binary all")
if res:
status = {'SUCCESS'}
else:
status = {'ERROR'}
self.report(status, msg)
return {'FINISHED'}
Raw pip calls using static _cmd method
Pip()._cmd("install", options, module)
From version 2.83, blender will no more expose user site-package in path. Ensure user site package method detect site package and add to sys.path when missing. Call this method from your init, before custom module(s) import
Pip.ensure_user_site_package()
In blender python console
from blender_pip import Pip
Pip.install("module_name=version")