4
$\begingroup$

I'm on macOS with a new install of Blender, current version as of now. I had some issues and finally managed to get pip working with the Blender install of Python and I'm adding modules I need to use in some scripts. (Such as Pillow, for adding ID info on rendered images then saving the blended images as PNGs.) So I have special modules set up in that instance of Python, which is entirely within the main Blender directory, in /Applications/Blender.

When I upgrade to a newer version of Blender, on Mac, that's generally done by drag-and-drop, which would lead to replacing everything in the old Blender install.

Is there a preset way to handle this that lets me install the new Blender and keeping the modules I've added to that Python install? Or do I just need to keep a record of what modules I add so when I get a new version of Blender, I can re-install pip and re-add all the modules I've added?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

Yes you will need to have a backup setup script which you have to manually keep and maintain that when executed will install ensurepip, pip, enable built-in addons, and install the third party addons, etc. Basically it would look something like the following script which you execute everytime you have a new Blender install:

import subprocess
import sys
import os

python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')

# install pip
subprocess.call([python_exe, '-m', 'ensurepip'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'pip'])

# Install Python Modules/Libraries/Packages
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'PACKAGE_NAME_1'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'PACKAGE_NAME_2'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'PACKAGE_NAME_3'])

# Enable built-in addons
# Enable addon 1
# Enable addon 2
# Enable addon 3

# Install third party addons
# Install addon 1
# Install addon 2
# Install addon 3

You can find more info here:

$\endgroup$
3
  • $\begingroup$ I'm looking this over - it's been so long since I wrote and used my add-on, but I will need it in the future. I just commented that I had asked about this in the Blender Artists forum - you didn't see my comment there, by any chance, and find this from that, did you? $\endgroup$
    – Tango
    Commented Jan 10, 2023 at 6:24
  • $\begingroup$ No, I went through some old unanswered questions and thought i'd put an answer. can you post a link to the blenderartist post $\endgroup$
    – Harry McKenzie
    Commented Jan 10, 2023 at 9:40
  • $\begingroup$ Not really necessary to post a link since the other post doesn't add any info. I want to test this out, which won't be immediately, to see how it works. With your extra sections to enable built-in and third party, do you mean that every time I upgrade Blender, I have to re-enable any add-ons I've started using? $\endgroup$
    – Tango
    Commented Jan 11, 2023 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .