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

2 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