SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mkdir ~/.config/blender/2.79/scripts/modules
  2. pip install -t ~/.config/blender/2.79/scripts/modules <python-package>
  3.      
  4. def fix_path():
  5.     """Enable 3rd party Python modules installed in an
  6.     active Virtualenv when Python is run.
  7.     (Blender ignores the virtualenv, and uses a
  8.     Python binary hardcoded in the build. This works
  9.     if the virtualenv's Python is the same as blenders')
  10.     """
  11.  
  12.     import sys, os
  13.     from pathlib import Path
  14.  
  15.     pyversion_path = f"python{sys.version_info.major}.{sys.version_info.minor}"
  16.  
  17.     for pathcomp in os.environ["PATH"].split(os.pathsep)[::-1]:
  18.         p = Path(pathcomp)
  19.         if p.name != "bin":
  20.             continue
  21.         lib_path = p.parent / "lib" / pyversion_path / "site-packages"
  22.         if not lib_path.exists():
  23.             continue
  24.         if str(lib_path) in sys.path:
  25.             continue
  26.         sys.path.insert(0, str(lib_path))
  27.  
  28.         print(f"{__name__} Add-on: prepended {lib_path!r} to PYTHONPATH")
  29.  
  30. fix_path()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top