How about a Linux - Replacing Bundled Python?

bpy_s01_pc__replacing_bundled_python

#1

Seeing as Blender has a respectable Linux user base, it would be great to see a video devoted to getting setup on that OS. I’m running Blender on Ubuntu 16.04 and am hoping to follow along with this tutorial series. Anyone else running a Linux distro and know how to handle pointing to a system level python install in Blender?


#2

It should be the same as with MacOS. Have you tried that?


#3

I gave that a try but couldn’t get it to work unfortunately. It didn’t seem to be as straight forward as linking a single directory, as I had to recreate the 2.78/python/ (bin, lib and include) directory structure that wasn’t mirrored in my /usr/bin/python.

When I tried to start blender, I would get this stack trace -

Failed to import the site module
Traceback (most recent call last):
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/site.py”, line 580, in
main()
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/site.py”, line 566, in main
known_paths = addusersitepackages(known_paths)
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/site.py”, line 287, in addusersitepackages
user_site = getusersitepackages()
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/site.py”, line 263, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/site.py”, line 253, in getuserbase
USER_BASE = get_config_var(‘userbase’)
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/sysconfig.py”, line 595, in get_config_var
return get_config_vars().get(name)
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/sysconfig.py”, line 538, in get_config_vars
_init_posix(_CONFIG_VARS)
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/sysconfig.py”, line 410, in _init_posix
from _sysconfigdata import build_time_vars
File “/usr/lib/blender-2.78a/2.78/python/lib/python3.5/_sysconfigdata.py”, line 6, in
from _sysconfigdata_m import *
ImportError: No module named ‘_sysconfigdata_m’

I’m going to fall back to the bundled python for now and try a few different approaches. But any guidance would be much appreciated…


#4

So it looks like installing blender from the website (blender.org) will provide a bundled python that I’m yet to work out how to replace. But using apt-get (package manager) installs a version of blender that points to the system install of python by default.


#5

There is s much easier solution than going through the replace python / logical links route.

What I did was just use my existing pip3 to install PIL in the blender lib directory.

Using my system level pip3 I typed the following:

pip3 install --target /home/my_home/blender/blender-2.78a-linux-glibc211-x86_64/2.78/python/lib/python3.5 pillow

There is a space betwwen …/lib/python3.5 and pillow in the line above (it may not be easy to see).

No having to mess with links or worry about messing up your current version of Python3 on the system level.

This should work for Windows and Mac as well (using pip instead of pip3), but I have not tested it.


#6

Per the blender docs, the easiest way is to just delete the bundled python (assuming you have the same version installed on your system)

https://docs.blender.org/api/blender_python_api_2_60_1/info_tips_and_tricks.html

I doubt this changed in 2.7


#7

Not reproducable / reliable!