Just to be extra thorough, here is the relevant info from the C4D documentation.
Hi @Dan_Bradham , this is fantastic, thank you so much! I’ve downloaded a copy of your branch (as I don’t really know how to make my config point specifically at your branch - git isn’t a strong point for me!) and it now loads up just fine!
Initially I struggled for several hours with repeated shiboken2 errors, even after adding the Python 3 site-packages location to my Python path, and the new C4d one too, I was about to give up after trying all kidns of permutations and additional code lines forcing it to add it from within the app, but to no avail, it refused to pick it up… And then I just copied the shiboken2 and PySide2 folders from the Shotgun Python3 location to C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37 and bang! Suddenly it suddenly it started loading!
I’m currently running into some saving\loading issues:
Failed to create folders:
Failed to load plugin V:\pipeline\shotgun\sgtk_configs\c4d_test\config\core\hooks\process_folder_creation.py. The following error was reported:
Exception: <class 'SyntaxError'> - invalid token (process_folder_creation.py, line 121)
Traceback (most recent call last):
File "V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python\tank\util\loader.py", line 59, in load_plugin
module = imp.load_source(module_uid, plugin_file)
File "C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib\imp.py", line 171, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
!
But that seems to be some error of the folder creation process itself, which is likely a template thing I guess, even though those all look OK, so I’ll look further into that! EDIT Looks like it’s failing to build the final folder, once that’s there it’s all fine. Odd, not run into the folder creation process just failing like that before.
I’ve also been able to add my own custom tool into the menu again, which is great, although oddly it won’t load when C4D opens, even though it’s in the initial menu in shotgun.pyp, I only see Save/Open at that point, but once I’m in another context, the tool then shows up in the menu. It’s listed in all the right places in the config seemingly. Not sure if you’ve encountered that? EDIT turns out it will add the menu item for it, but won’t actually run it. No errors in the console, it just does nothing. Which is very odd as if I swap back to R21, it loads up just fine. But not in R23… I’m not sure what else it would be treating differently between the two versions other than the Pyhtonpath which might explain that, and the Pythonpath wouldn’t make sense as an issue in this case. The fact that it doesn’t throw any kind of an error is extremely unhelpful…
Once again thanks for sharing you’re working version, this is a massive help to me, and no doubt many others! I really appreciate it :).
That SyntaxError could mean you have some code in your process_folder_creation that’s incompatible with python3. However, the traceback you posted is incomplete so it’s difficult to know the full story.
On a side note, I’d be wary of placing dependencies like QT and shiboken into your Cinema4D python folder. That will become unmanageable as you’d need to do it for every machine on site.
Are you on the latest version of shotgun desktop and do you have SHOTGUN_PYTHON_VERSION set to 3?
Hi Dan, that was the error as displayed in the Shotgun pop up. I’ll try again soon and see if I can get a fuller read out from the log.
We have very few users of C4D, so manually copying the files across is totally fine for us - I can understand that not being exactly best practise, but I could not get it to work any other way. I think because it was also trying to run the Python 2 version of things before getting to the Python3 version in the PATH, so by providing the version it cares about in the first place it looks, it bypasses that.
I don’t have SHOTGUN_PYTHON_VERSION set to anything. Most of our DCCs are still on python 2.7, so I don’t to tell Shotgun to be only using Python 3 - unless that wouldn’t make any actual difference here?
Thanks very much for your help!
@jhudsonFP I’ve merged you pr in my tk-cinema repository. It’s very cool that you made python3 capability. I will try to touch to shotgun-cinema setup in nearest week, maybe I will find some issues. Anyway thanks for you contribution in this stuff.
It was Dan’s pull request, not mine!
Hello again everyone! Has anyone got this working for R24/25? I can see that tk-cinema was updated for R24, however I can’t get it to actually work.
I get “Unable to import shiboken2” as the error on start up. More specifically if I try and import shiboken2 in C4D’s python console, I get this:
Traceback (most recent call last):
File "V:\resource\users\Jon H\PyCharmProjects\tk-cinema-master\startup\shotgun.pyp", line 54, in <module>
engine = sgtk.platform.start_engine(env_engine, context.sgtk, context)
File "V:/pipeline/shotgun/sgtk_configs/studio/install/core/python\tank\platform\engine.py", line 3013, in start_engine
return _start_engine(engine_name, tk, None, context)
File "V:/pipeline/shotgun/sgtk_configs/studio/install/core/python\tank\platform\engine.py", line 3173, in _start_engine
engine = class_obj(tk, new_context, engine_name, env)
File "V:/pipeline/shotgun/sgtk_configs/studio/install/core/python\tank\platform\engine.py", line 198, in __init__
self.pre_app_init()
File "V:\resource\users\Jon H\PyCharmProjects\tk-cinema-master\engine.py", line 261, in pre_app_init
utf8 = QtCore.QTextCodec.codecForName("utf-8")
AttributeError: 'NoneType' object has no attribute 'QTextCodec'
Tue Mar 15 13:59:57 2022 - Shotgun Debug | Cinema engine | Debug: Shotgun pyp: Attempting to use Current Engine...
Traceback (most recent call last):
File "V:\resource\users\Jon H\PyCharmProjects\tk-cinema-master\startup\shotgun.pyp", line 63, in <module>
raise RuntimeError(
RuntimeError:Failed to load tk-cinema! Can not start or find engine.
HELLO WORLD
Traceback (most recent call last):
File "C:\Users\jhudson\Documents\c4d.py", line 2, in <module>
import shiboken2
File "C:\Program Files\Maxon Cinema 4D R24\resource\modules\python\libs\python39\shiboken2\__init__.py", line 27, in <module>
from .shiboken2 import *
ImportError: DLL load failed while importing shiboken2: The specified module could not be found.
I’ve looked up the error and other people seem to get it from incompatible python versions, but R24/5 are on 3.9, which as far as I’m aware should be fine.
Anyone else (@Dan_Bradham?) actually got it working/have any ideas about the above issue? Thanks very much.
Hey @jhudsonFP,
Unfortunately the build of Python that cinema4d includes is incompatible with the PySide2 included with ShotGrid Desktop. This is because cinema4d’s Python was built with an older version of Microsoft Visual Studio. In order to get things working properly I had to build Python and PySide2 against the same version of Microsoft Visual Studio that Maxon used to build c4dpy.
I threw the resulting wheels up in this repository if you would like to try them out:
P.S. The same wheels worked for me for both S24 and R25.
Dan, that’s worked perfectly, thank you so much!
Excellent, glad I could help. Hopefully R26 doesn’t use another Python version haha. I think I spent 3-4 days getting those builds correct!
Hello Members,
I tried the above steps recommended to make the cinema4d R23 work with ShotGrid on the Mac. I have added the PythonPath and C4DPythonpath37 in the ~/bash_profile and also added them as an env variable in the before_app_launch.py which should initialise the environment variables pointing to the site packages for shotgun and Maxon cinema4d R23. Also, I have tried to use the fork from https://github.com/danbradham/tk-cinema and configured the engine.yml to use the tk-cinema engine.
Moreover, I have also manually copied the pyside2 and shobiken2 packages in the Maxon site-packages which are/Applications/MAXON/“Cinema 4D R23”/resource/modules/python/libs/python37 here as a fix which was tried by one of the users as a potential solution.
Questions
- Is before_app_launch.py the correct place to add the environment variables stated above?
- Is there anything which is wrong here? I am just new to the cinema4d and shotgun and have been trying to set it up on the Mac but is always running into issues?
Please find the stack trace here
Traceback (most recent call last):
File "/Users/saurabhbansal/Library/Caches/Shotgun/xyz/p122c2.basic.desktop/cfg/install/core/python/tank/platform/engine.py", line 2140, in _define_qt_base
importer = QtImporter()
File "/Users/saurabhbansal/Library/Caches/Shotgun/xyz/p122c2.basic.desktop/cfg/install/core/python/tank/util/qt_importer.py", line 51, in __init__
) = self._import_modules(interface_version_requested)
File "/Users/saurabhbansal/Library/Caches/Shotgun/xyz/p122c2.basic.desktop/cfg/install/core/python/tank/util/qt_importer.py", line 381, in _import_modules
pyside = self._import_pyside()
File "/Users/saurabhbansal/Library/Caches/Shotgun/xyz/p122c2.basic.desktop/cfg/install/core/python/tank/util/qt_importer.py", line 188, in _import_pyside
self._to_version_tuple(QtCore.qVersion()),
AttributeError: 'NoneType' object has no attribute 'qVersion'
2022-04-11 18:11:30,362 [15782 DEBUG sgtk.core.util.qt_importer] Requesting Qt5-like interface
2022-04-11 18:11:30,364 [15782 DEBUG sgtk.core.util.qt_importer] No Qt matching that interface was found.
2022-04-11 18:11:30,364 [15782 ERROR sgtk.ext.shotgun.pyp] Error starting engine...
I am also interested in knowing the solution to this.
Hey @Dan_Bradham !
Thanks for the effort, but still I am a bit confused. IDK where to put these wheels. What to do with them? Put them in some folder and then install it? If so, what pip should be used (I did not find any other tool except for Python39 that came with the Cinema 4d Installation)
Another thing, there is a probability that these wheel files don’t work with my Cinema installation (due to maybe different MVS compiler). So if that is the case, I would need to build it on my own. Then I have the problem to find out what is the version of MVS I need for building PySide from source code. Do you know how to find the version that has been used to build my, installed Cinema 4D?
Kind Regards, and thanks in advance,
Srdjan
I guess one of my questions here is, are all of you on standalone (on prem) or are you running the regular version of shotgrid?
I wish someone would put up a straight fwd video for this whole install process!