Python 3.7 requirement

I frequently encounter build issues because Blender depends on a fairly recent version of Python 3. For example, Ubuntu 18.04 LTS and CentOS 8 ship with Python 3.6, which requires to manually install python 3.7 to build a recent version of Blender. Further, there are already plans to introduce Python 3.8 which will then break compatibility with Debian, another long-term supported Linux distribution.

Are there sensible reasons to depend on features of the most recent Python version?

Which exclusive Python 3.7 features are currently in use that justify upgrading Python versions and potentially breaking compatibility with user code? And which features of Python 3.8 are required for future Blender versions?

If these features are not required, it would be beneficial to make those optional and enable building with older Python version.

We’re gonna stick with 3.7 for at least the rest of this year .

4 Likes

Blender ships with its own version of Python, so for normal users it does not matter what the system’s Python is. If you do development work, it is easy (and even recommended) practice to make use of virtual environments / Anaconda environments.

What would be a reason to not upgrade to have access to new features? As a add-on developer, I’m happy there is support for Postponed Evaluation of Annotations among others. And upgrading between minor versions in Python 3.x is usually problem free.

Does this also hold, if a user wants to use the Blender bindings and other third-party packages, e.g. those at PyPI? If Blender switches to Python 3.8, a user has to install these additional packages within Blender’s Python environment. Or am I missing something here?

Of course, if there is a frequently requested feature, it makes sense to upgrade the version.
However, the general policy should be that upgrades are well justified and not a result of simply depending on the most recent version just because it has the highest version number.

Does this also hold, if a user wants to use the Blender bindings and other third-party packages, e.g. those at PyPI? If Blender switches to Python 3.8, a user has to install these additional packages within Blender’s Python environment.

Even if you have Python 3.7 on your system and use Blender with Python 3.7, Blender still uses it’s internal Python. So if you install a library in your system’s Python, Blender cannot use it. You can delete Blender’s Python, so it will use your system’s one, or other methods: https://docs.blender.org/api/current/info_tips_and_tricks.html#bundled-python-extensions

Actually, there is a undocumented method, which is to enable pip in Blender’s Python itself:

  • Not sure if this method still works though, because I encountered that in Blender 2.81 ensurepip was removed?

Of course, if there is a frequently requested feature, it makes sense to upgrade the version.
However, the general policy should be that upgrades are well justified and not a result of simply depending on the most recent version just because it has the highest version number.

Blender’s community comes in a large variety and doesn’t have a single user type. What might be unimportant to one user, might be a life safer in another. If you come across such method, but say it’s only in 3.8, you have to wait till Blender upgrades, even if you request it. This staying up-to-date with technology is one of the reasons Blender is now popular, in comparison with Maya only now moving away from 2.7…

Edit: Nevermind, 2.81 comes with pip enables by default, so no need for ensurepip: https://developer.blender.org/T71856

Edit 2: You would install your library through pip in this way:

import subprocess
pybin = bpy.app.binary_path_python
subprocess.check_call([pybin, '-m', 'pip', 'install', 'your_library'])

Edit 3: Added pybin, '-m' , otherwise it can install the package in a Python environment which is not Blender’s one.

I can confirm this- at my studio my addons are deployed to users with varying Python experience so the ‘local version’ is all over the place. IE) there are technical artists using Houdini, Maya. More than a handful are still on 2.7. Rank and file artists sometimes don’t even have Python installed at all. For my addons, I spin up a local Flask server for documentation, so all I do is check to see if the module exists, if not- i use pip to install it (as demonstrated above). Works great in every strange environment I’ve tested it in.

The code I posted about pip in Blender was not completely correct, please see the last update 2 post above.