Scripting through external console on windows 10

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

SetupSucks

  • Posts: 2
  • Joined: Sat Apr 27, 2024 4:36 pm
  • Real Name: bob random

Scripting through external console on windows 10

PostSat Apr 27, 2024 4:39 pm

Hi,

I have been trying to just run one of the example scripts but i just get:
Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations
Traceback (most recent call last):
File "C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Examples\1_sorted_timeline_from_folder.py", line 31, in <module>
projectManager = resolve.GetProjectManager()
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'GetProjectManager'

however i have followed the readme to set the enviroment variables so i am not sure why it is not finding the python - any help would be appreciated
Offline
User avatar

Stefan Weßling

  • Posts: 30
  • Joined: Thu Oct 30, 2014 2:00 am

Re: Scripting through external console on windows 10 -

PostWed May 01, 2024 9:59 pm

I've ran into numerous issues using python inside resolve.
My recommendation would be external python.

    - Use a IDE of your choice (PyCharm, Thonny...)
    - make sure resolve is started and a project is opened
    - Use the loader provided in the link (or write your own)
    - run script inside the IDE
    - do your stuff

https://github.com/swdit/MultiOS_ResolveHead_V3/blob/master/MultiOS_ResolveHead_V3.py
Offline
User avatar

SeldomSeenKid

  • Posts: 397
  • Joined: Mon May 31, 2021 1:16 pm
  • Location: Germany
  • Real Name: Michael Adrian

Re: Scripting through external console on windows 10

PostThu May 02, 2024 7:03 am

Interesting! Is this possible with LUA too?
Good judgement comes from experience. Experience comes from bad judgement.
# Threadripper 32 core / 160GB / RTX4000 8GB / WIN10 #
# BMCC / DVR17.4.6 Studio / Speed Editor / Tangent Ripple / X-Touch One / X-Touch mini / Space Explorer / 5.1 HDMI#
Offline
User avatar

Igor Riđanović

  • Posts: 1612
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Scripting through external console on windows 10

PostThu May 02, 2024 5:34 pm

SeldomSeenKid wrote:Interesting! Is this possible with LUA too?


Yes. Lua is automatically installed by the Resolve installer, but for internal scripting also. I'm not sure if one can run the interpreter from outside of Resolve. I've never tried to actually find it on the file system.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

  • Posts: 1612
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Scripting through external console on windows 10

PostThu May 02, 2024 5:38 pm

SetupSucks wrote:Hi,

I have been trying to just run one of the example scripts but i just get:
Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations
Traceback (most recent call last):
File "C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Examples\1_sorted_timeline_from_folder.py", line 31, in <module>
projectManager = resolve.GetProjectManager()
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'GetProjectManager'

however i have followed the readme to set the enviroment variables so i am not sure why it is not finding the python - any help would be appreciated


Here, just use this to make a resolve instance for external scripting in Windows. It's straight from the sample scripts that come with Resolve. You can paste this in your Python interpreter, but you can't go higher than Python 3.6:
Code: Select all
import imp

library = 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll'
bmd = imp.load_dynamic('fusionscript', library)
resolve = bmd.scriptapp('Resolve')
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

roger.magnusson

  • Posts: 3411
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Scripting through external console on windows 10

PostThu May 02, 2024 5:40 pm

Yes, the executable for the interpreter is called "fuscript" and it can run LuaJIT or Python.
Code: Select all
Usage: fuscript [opts] <script> [args]
   -i                   - Enter interactive mode
   -v                   - Print version information
   -s                   - Run as script server
   -S                   - Run as script server with no timeout
   -p [appname]         - Ping script apps
   -P [appname]         - Ping script apps (longer timeout)
   -q                   - Be quiet
   -b                   - Run with commandline debugger
   -l <lang>            - Explicitly set language, from:
      lua
      py2 or python2
      py3 or python3
   -x <string>          - Execute string
Offline
User avatar

SeldomSeenKid

  • Posts: 397
  • Joined: Mon May 31, 2021 1:16 pm
  • Location: Germany
  • Real Name: Michael Adrian

Re: Scripting through external console on windows 10

PostFri May 03, 2024 7:05 am

Wow... thanks for the insight Roger. This might change the way I am working so far. I have a rather long LUA script running inside resolve, which can drop the playback performance depending on what it's doing. Maybe I can split it into different threads with external LUAJIT.
Good judgement comes from experience. Experience comes from bad judgement.
# Threadripper 32 core / 160GB / RTX4000 8GB / WIN10 #
# BMCC / DVR17.4.6 Studio / Speed Editor / Tangent Ripple / X-Touch One / X-Touch mini / Space Explorer / 5.1 HDMI#

Return to DaVinci Resolve

Who is online

Users browsing this forum: Google [Bot], panos_mts, Shrinivas Ramani, tlegvold, Uli Plank and 102 guests