Skip to content

Instantly share code, notes, and snippets.

@xunkai55
Last active March 16, 2022 00:39
Show Gist options
  • Save xunkai55/6331fdd3446257cf5b4a98f202727245 to your computer and use it in GitHub Desktop.
Save xunkai55/6331fdd3446257cf5b4a98f202727245 to your computer and use it in GitHub Desktop.
Setup bpy (Blender as a python module) on Mac OS X
# Do not excute the script directly. It is just for demonstration.
# If you followed the documentation and got the errors below, please take a look at this guide.
# Color management: using fallback mode for management
# bpy: couldnt find 'scripts/modules', blender probably wont start.
# Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.
# ImportError: No module named 'bpy_types'
# ImportError: No module named 'bpy_types'
# pyrna_srna_ExternalType: failed to find 'bpy_types' module
# ImportError: No module named 'bpy_types'
# ImportError: No module named 'bpy_types'
# pyrna_srna_ExternalType: failed to find 'bpy_types' module
# ImportError: No module named 'bpy_types'
# pyrna_srna_ExternalType: failed to find 'bpy_types' module
# F0102 21:06:58.742173 1895752448 utilities.cc:322] Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
# "
# Firstly, download the source and excute "make bpy" things.
cd $THE_FOLDER_YOU_BUILD/bin
# Now you should find bpy.so and 2.xx directory here.
# If you type python3 and `import bpy` here, you would get the error messages above.
# Don't worry.
mkdir ../Resources
mv 2.78 ../Resources/
# Change the version number if is out of date.
# Try the test script. It could be good now.
python3 -c "import bpy ; bpy.ops.render.render(write_still=True)"
# Of course, if you want to setup bpy in somewhere else,
# you have to do something just like `mkdir ../Resources; mv 2.78 ../Resources`.
@m-clare
Copy link

m-clare commented Sep 14, 2020

@Gaurav1302, I tried the solution here to no avail, and then I also tried renaming the folder to config-3.7m (removing the darwin suffix), and still ended up with the same errors:

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [bin/bpy.so] Error 1
make[2]: *** [source/creator/CMakeFiles/blender.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

@Gaurav1302
Copy link

Gaurav1302 commented Sep 14, 2020

@m-clare, I couldn't make this work on a Mac. So, I dual-booted my PC to Linux (Ubuntu) and it worked perfectly for me. It was much easier to use Blender over a Linux system. I suggest you switch to a Linux system instead of trying to figure out a way to make it work on a Mac. I assure you, it's much simpler.

@lakpa-tamang9
Copy link

@Gaurav1302, How did you install bpy in Ubuntu? I have Ubuntu 18.04 with python 3.7. I have tried several methods, still not able to do so correctly. Can you help me out here?

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