
- Posts: 12
- Joined: Tue Dec 19, 2023 3:38 pm
- Real Name: Jean Callisti
(DaVinciResolve 18.6.2)
Hello,
i am confused with the proper way of running Python scripts externally (i.e. not from the Py3 console inside DaVinci Resolve). On Windows.
I followed the following flow:
1) Check that all required env variables are set :
Either in Windows command-line syntax, like this, in a .bat file just before executing the python script:
...Or directly in Python from within the script
Because I'm paranoid (and out of desperation), I also add the "/Modules" folder this way :
2) Write my own script
In it absolute simplest version, if does nothing else than importing DaVinciResolveScript:
=======
I tried running that script with several versions of Python. All of them fail, every time because of the "imp" package used by DaVinciResolveScript.
With Python 3.12 (i.e. the most recent Python):
PROBLEM : My script was working until the import of DaVinciResolveScript.py, which was crashing as early as its first line, because internally it imports module "imp" which is entirely deprecated in Python 3.12. You can't even use it anymore, it's a blocking deprecation.
Python 3.9 or 3.11 (slightly older versions) :
Module "imp" is still marked as deprecated, but at least it doesn't cause a crash to import it.
PROBLEM: When DaVinciResolveScript hits this instruction, it fails:
The issue is that it's not clear how or why it fails. It doesn't crash, it doesn't throw an error or raise an exception. But then the execution seems to ... vanish? The debugger has no steps to follow after it.
Maybe the execution enters a different thread/process to which the debugger is not attached? Is it just me who just lacks basic knowledge of how to debug Python modules?
Either way, it's no good.
I tried the recommended version : 3.6
PROBLEM: I can't even run the code in debug. VSCode's Python extension won't go further back than 3.7.
I tried to run the script from the command line, without being attached to a debugger. The import still seems to fail.
What am I doing wrong? Do you have a recommendation or a step-by-step guide?
Hello,
i am confused with the proper way of running Python scripts externally (i.e. not from the Py3 console inside DaVinci Resolve). On Windows.
I followed the following flow:
1) Check that all required env variables are set :
Either in Windows command-line syntax, like this, in a .bat file just before executing the python script:
- Code: Select all
RESOLVE_SCRIPT_API="%PROGRAMDATA%\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\"
RESOLVE_SCRIPT_LIB="C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll"
PYTHONPATH="%PYTHONPATH%;%RESOLVE_SCRIPT_API%\Modules\"
...Or directly in Python from within the script
- Code: Select all
Not detailed here
Because I'm paranoid (and out of desperation), I also add the "/Modules" folder this way :
- Code: Select all
sys.path.append(".../Modules")
2) Write my own script
In it absolute simplest version, if does nothing else than importing DaVinciResolveScript:
- Code: Select all
try:
import DaVinciResolveScript as dvr
except ImportError:
print("could not import DaVinciResolveScript")
exit(1)
=======
I tried running that script with several versions of Python. All of them fail, every time because of the "imp" package used by DaVinciResolveScript.
With Python 3.12 (i.e. the most recent Python):
PROBLEM : My script was working until the import of DaVinciResolveScript.py, which was crashing as early as its first line, because internally it imports module "imp" which is entirely deprecated in Python 3.12. You can't even use it anymore, it's a blocking deprecation.
Python 3.9 or 3.11 (slightly older versions) :
Module "imp" is still marked as deprecated, but at least it doesn't cause a crash to import it.
PROBLEM: When DaVinciResolveScript hits this instruction, it fails:
- Code: Select all
script_module = imp.load_dynamic("fusionscript", path + "fusionscript" + ext)
The issue is that it's not clear how or why it fails. It doesn't crash, it doesn't throw an error or raise an exception. But then the execution seems to ... vanish? The debugger has no steps to follow after it.
Maybe the execution enters a different thread/process to which the debugger is not attached? Is it just me who just lacks basic knowledge of how to debug Python modules?
Either way, it's no good.
I tried the recommended version : 3.6
PROBLEM: I can't even run the code in debug. VSCode's Python extension won't go further back than 3.7.
I tried to run the script from the command line, without being attached to a debugger. The import still seems to fail.
What am I doing wrong? Do you have a recommendation or a step-by-step guide?