Getting shotgrid working with Blender 3.0?

We have been trying to get ShotGrid working with Blender 3.0 on linux using this integration: GitHub - diegogarciahuerta/tk-blender: Shotgun Toolkit Engine for Blender: https://www.blender.org/ and have been having some trouble.

In Blender 2.93 the Shotgun menu appears and works (although slowly). I’m 3.0, we can get the menu to appear but it’s always blank.
It looks like it’s an issue with the context not being set correctly, but I’m not positive.

Has anyone else been able to get it working in Blender 3.0a on linux?

Cheers,
Jason

1 Like

How do you install PySide? We haven’t tried with 3.0, though.

We’re pointing to a PySide that’s installed outside our Blender app by setting the PYSIDE2_PYTHONPATH environment variable as specified in the README here: GitHub - diegogarciahuerta/tk-blender: Shotgun Toolkit Engine for Blender: https://www.blender.org/

Have you checked the Blender output console for errors? There might be some appearing right when you open the menu.

Unfortunately I can’t figure out how to see the output from Blender when launching from ShotGrid on Linux… I’ve enabled the console in Shotgrid, but it’s not capturing the normal Blender output. For example - if I launch blender from a Shell, I can see the output of print statements/etc. But those aren’t showing up when launched from ShotGrid.

The way I do it when there is no output window is to start the program using tank, for example

./tank blender_2.93.4

the exact program identifier will depend on you Software entity’s code.
This way stdout goes to the terminal where you launched the program.
You can even do

./tank Task "@123" blender_2.93.4

to start in a specific task, and even launch with a scene open (don’t have the exact command right now).

ah! that’s awesome, didn’t know I could do that… I’ll poke around and see what I can figure out!

Yeah that’s neat. Though I’d still wish to see Shotgun capturing the output somewhere, e.g. in the Destkop log.

Totally. That’d be awesome.

In any case, I can see that when I’m running blender 3.0, I’m getting an issue with import QtGui from tank/platform/qt/init.py, but I’m not getting the same error when running blender 2.93 - so I’m not sure what the difference is between the two… gotta figure out what’s happening. Thank you for the poke in the right direction, though!

I’ve attached the error I’m getting when running Blender 3.0a… not getting it when running 2.93:

And I’m running them both the same way…

# works - no qt error
tank blender_2.93

# doesn't work getting the qt error
tank blender_3.0a
Tue Sep 28 21:39:05 2021 | Error | Shotgun Blender Engine | Shotgun: Could not start engine. Details: cannot import name 'QtGui' from 'tank.platform.qt' (/mnt/fsxshare/app_env/shotgun/demo_config/install/core/python/tank/platform/qt/__init__.py)Traceback (most recent call last):
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/git/tk-blender/v1.1.1/startup/bootstrap.py", line 106, in start_toolkit_classic
    engine = sgtk.platform.start_engine(env_engine, context.sgtk, context)
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/core/python/tank/platform/engine.py", line 3013, in start_engine
    return _start_engine(engine_name, tk, None, context)
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/core/python/tank/platform/engine.py", line 3173, in _start_engine
    engine = class_obj(tk, new_context, engine_name, env)
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/git/tk-blender/v1.1.1/engine.py", line 232, in __init__
    Engine.__init__(self, *args, **kwargs)
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/core/python/tank/platform/engine.py", line 169, in __init__
    self.init_engine()
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/git/tk-blender/v1.1.1/engine.py", line 388, in init_engine
    self.show_info(msg)
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/git/tk-blender/v1.1.1/engine.py", line 271, in show_info
    self.show_message(msg, level="info")
  File "/mnt/fsxshare/app_env/shotgun/demo_config/install/git/tk-blender/v1.1.1/engine.py", line 239, in show_message
    from sgtk.platform.qt import QtGui, QtCore
ImportError: cannot import name 'QtGui' from 'tank.platform.qt' (/mnt/fsxshare/app_env/shotgun/demo_config/install/core/python/tank/platform/qt/__init__.py)

The only thing I could think of was that perhaps the PYSIDE2_PYTHONPATH environment variable wasn’t working, and that PySide and Qt were included installed with the Blender 2.93 app, but not with Blender 3.0a… so I checked the site-packages folder in both, and they’re the same…

certifi  chardet  idna  libextern_draco.so  numpy  PySide2  PySide2-5.15.2.dist-info  requests  shiboken2  shiboken2-5.15.2.dist-info  urllib3

I’m not sure why that is. It could be that Blender 3 uses a much newer Python, and it is somehow incompatible with the PySide2 you have…
You could try an interactive python shell (directly in terminal) with Blender 3’s python and have a look around PySide (try to import, also through tank, etc.)
You might get a clearer error.

Any chance you had any luck getting this to work?

Sadly, no… we never got it working. :frowning:

whoa! for real? This seems like such a stupid problem.

I feel like it’s an issue with Tank Core. because when load up blender outside of shotgrid and append the correct paths I still get the same issue. I can run from sgtk.platform.qt import QtGui, QtCore in 2.93 just fine but not in 3.0.

It seems like the python version between the 2 releases was only a minor change blender 2.93 = python 3.9.2 and blender 3.0 = 3.9.7

1 Like

Found a solution to the ImportError, if you set SGTK_COMPATIBILITY_DIALOG_SHOWN you wont get this error anymore.

tk-blender wants to warn you that its might not be compatible with blender +3.0 anymore and tries to create and show a dialog before QtGui is added to tank.platform.qt

I hope this help,
Stefan

3 Likes

Great Find! You sir are a hero. Any thoughts on how to make this work without disabling the compatibility Dialog?

Found this the other day, its possible to increase the compatibility_dialog_min_version in the tk-blender config, it doesnt fix the issue but another way.

I just posted these in another thread involving Cinema4D. Personally I had to rebuild PySide2 for Blender 2.9.3, I’m not sure how it worked for you with SG Desktops included PySide2 build. But…you can try the wheels here I made for Blender 2.9.3, if Blender 3.0 is truly a minor version bump they may still be applicable.

If they don’t work let me know, I had planned on rebuilding PySide2 for Blender 3.0 as well. Just not sure when I’ll get around to it. Newer versions of Blender will jump to the latest release of Python which likely means rebuilding PySide2 more frequently. I have expressed to a member of the Blender development team that they should be building Blender and blender python with the same Microsoft Visual Studio build that CPython is built with to avoid compatibility issues with python packages found in the python package index. I don’t have much hopes in that being acted on but, we’ll see what happens.

2 Likes

Hi all, I’ve been trying to get the same SG integration for Blender 3.1 and I’ve been having the same import error:

Mon Apr 4 09:04:14 2022 | Error | Shotgun Blender Engine | None
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun log: Debug logging enabled. To permanently enable it, set the TK_DEBUG environment variable.
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun log: Setting TK_DEBUG in the environment for this session. This ensures that subprocesses spawned from this process will inherit the global debug logging setting from this process.
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun tk-blender: Detected setting ‘config/env/project.yml:tk-blender.debug_logging: true’ in your environment configuration. Turning on debug output.
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun tk-blender: Engine init: Instantiating <Sgtk Engine 0x2882bdfa590: tk-blender, env: project>
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun tk-blender: Engine init: Current Context: Project Andreas Test Project
Mon Apr 4 09:04:16 2022 | Debug | Shotgun Blender Engine | Debug: Shotgun tk-blender: <Sgtk Engine 0x2882bdfa590: tk-blender, env: project>: Initializing…
Mon Apr 4 09:04:16 2022 | Error | Shotgun Blender Engine | Shotgun: Could not start engine. Details: cannot import name ‘QtGui’ from ‘tank.platform.qt’ (M:\shows/andreas-test-project/pipeline/install/core/python\tank\platform\qt_init.py)Traceback (most recent call last):
File “M:\shows\andreas-test-project_pipeline\install\git\tk-blender.git\v0.0.1\startup\bootstrap.py”, line 108, in start_toolkit_classic
engine = sgtk.platform.start_engine(env_engine, context.sgtk, context)
File “M:\shows/andreas-test-project/_pipeline/install/core/python\tank\platform\engine.py”, line 3013, in start_engine return _start_engine(engine_name, tk, None, context)
File “M:\shows/andreas-test-project/_pipeline/install/core/python\tank\platform\engine.py”, line 3173, in _start_engine
engine = class_obj(tk, new_context, engine_name, env)
File “M:\shows\andreas-test-project_pipeline\install\git\tk-blender.git\v0.0.1\engine.py”, line 234, in init
Engine.init(self, *args, **kwargs)
File “M:\shows/andreas-test-project/_pipeline/install/core/python\tank\platform\engine.py”, line 169, in init
self.init_engine()
File “M:\shows\andreas-test-project_pipeline\install\git\tk-blender.git\v0.0.1\engine.py”, line 390, in init_engine
self.show_info(msg)
File “M:\shows\andreas-test-project_pipeline\install\git\tk-blender.git\v0.0.1\engine.py”, line 273, in show_info
self.show_message(msg, level=“info”)
File “M:\shows\andreas-test-project_pipeline\install\git\tk-blender.git\v0.0.1\engine.py”, line 241, in show_message
from sgtk.platform.qt import QtGui, QtCore
ImportError: cannot import name ‘QtGui’ from ‘tank.platform.qt’ (M:\shows/andreas-test-project/pipeline/install/core/python\tank\platform\qt_init.py)

Anyone found a way around it ?

Hello,

On my side, It works fine on windows 10 (blender 3.3.1).

On Linux (centos), with all versions I tried, I have the “Shotgun” menu (you have to set show_warning_dlg = False so you skip the error with show_message 'cannot import name ‘QtGui’ from ‘tank.platform.qt’), you still have the warning in your terminal. (Shotgun tk-blender: The Shotgun Pipeline Toolkit has not yet been fully tested with Blender 3.3. You can continue to use Toolkit but you may experience bugs or instability.)

But, it doesn’t refresh the app dialog I open (tk-multi-shotgunpanel or tk-multi-workfiles), I have to click on the menu twice, then the dialog appear but all black, if I click on the menu again, the widgets appears, then if I click on a widget, I have to click on the menu again, so event are processed, and so on …
It seems that the events are not processed if the menu is not activated.

Louise

On my side the integration is working on Blender 3.3.4 by setting the env var

as pointed out…

Now the only thing missing (and present in 2.82a) is the Publish action from the SG Menu.
I use the SG file open, make a new scene for an asset/task and save it. In Blender 2.82a the Publish action will appear while in 3.3.4 not. All templates and configs are the same.

Has this come across any of you already?


… let me add that if I print the engine’s commands, as described here:

In Blender 2.82a I do get the Publish Engine.register_command callback, while in 3.3.4 not


I found the error, here the traceback:

ERROR sgtk.env.project.tk-blender] App T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3 failed to initialize. It will not be loaded.
Traceback (most recent call last):
  File "T:\sg_tk/test_config_clone/install/core/python\tank\platform\engine.py", line 2793, in __load_apps
    app.init_app()
  File "T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3\app.py", line 30, in init_app
    tk_multi_publish2 = self.import_module("tk_multi_publish2")
  File "T:\sg_tk/test_config_clone/install/core/python\tank\platform\bundle.py", line 461, in import_module
    imp.load_module(
  File "C:\lbox\apps\blender-3.3.4-windows-x64\3.3\python\lib\imp.py", line 245, in load_module
    return load_package(name, filename)
  File "C:\lbox\apps\blender-3.3.4-windows-x64\3.3\python\lib\imp.py", line 217, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3\python\__init__.py", line 11, in <module>
    from . import tk_multi_publish2  # noqa
  File "C:\lbox\apps\blender_libs\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3\python\tk_multi_publish2\__init__.py", line 13, in <module>
    from .api import PublishManager  # noqa
  File "C:\lbox\apps\blender_libs\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3\python\tk_multi_publish2\api\__init__.py", line 11, in <module>
    from .data import PublishData  # noqa
  File "C:\lbox\apps\blender_libs\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "T:\sg_tk\test_config_clone\install\app_store\tk-multi-publish2\v2.6.3\python\tk_multi_publish2\api\data.py", line 18, in <module>
    class PublishData(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
2 Likes