required_modules.py 914 B

123456789101112131415161718192021222324252627282930
  1. import bpy
  2. from subprocess import run
  3. # get python's binary path (literally my saviour)
  4. py_bin = bpy.app.binary_path_python
  5. pip_install = [py_bin, "-B", "-m", "pip", "install",
  6. "--trusted-host", "pypi.python.org",
  7. "--trusted-host", "files.pythonhosted.org",
  8. "--trusted-host", "pypi.org",
  9. "-U", "--force-reinstall", "--only-binary", ":all:"]
  10. upd_mods = ["pip", "wheel", "setuptools"]
  11. new_mods = ["lxml"]
  12. try:
  13. import pip
  14. import lxml
  15. except:
  16. # hecking install pip (ensurepip) + required modules
  17. run([py_bin, "-B", "-m", "ensurepip"])
  18. # update basic modules then download new modules
  19. run(pip_install + upd_mods)
  20. run(pip_install + new_mods)
  21. print("First exit!")
  22. bpy.ops.wm.quit_blender()
  23. exit(0)
  24. # print module's versions installed
  25. print("pip %s is installed!" % (pip.__version__))
  26. print("lxml %s is installed!" % (lxml.__version__))