Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created April 13, 2022 13:33
Show Gist options
  • Save zeffii/db5ad6477a9cef242e8219d57106c609 to your computer and use it in GitHub Desktop.
Save zeffii/db5ad6477a9cef242e8219d57106c609 to your computer and use it in GitHub Desktop.
pip and blender instructions

Windows

pip now comes pre-installed with Blender's python.

Installing self contained libraries will usually be a matter of doing this in cmd

python -m pip install your_library

it can be done via TextEditor too (from: nortikin/sverchok#3968 (comment) )

import sys
import os
import subprocess

def install_package(package):
    if not isinstance(package, list):
        package = [package]
    subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", *package])
    
if __name__ == '__main__':
    install_package(['--upgrade', 'pip'])
    install_package('some_package_name')
@zeffii
Copy link
Author

zeffii commented Apr 13, 2022

@zeffii
Copy link
Author

zeffii commented Apr 15, 2022

from wheel?! :)

import sys
import os
import subprocess

def install_package(package):
    if not isinstance(package, list):
        package = [package]
    subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", *package])

def install_whl(package_path):
    subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", f"{package_path}"])
    

if __name__ == '__main__':
    ## install_package(['--upgrade', 'pip'])  <-- may not be needed
    # install_package('pandas')
    ## install_package('gdal')  <-- may fail
    ## install_package('fiona')  <-- may fail.
    # install_whl(r"C:\Users\zeffi\Downloads\GDAL-3.4.2-cp310-cp310-win_amd64.whl")
    # install_whl(r"C:\Users\zeffi\Downloads\Fiona-1.8.21-cp310-cp310-win_amd64.whl")
    # install_package('geopandas')
    # install_package('pygeos')   <-- optional
    # install_package('shapely')  <-- optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment