Problem loading fusionscript.dll via Python on Windows 10

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Problem loading fusionscript.dll via Python on Windows 10

PostTue Oct 04, 2022 6:35 pm

Hello,

I'm working on a tool that is using the Resolve 18 API ( https://github.com/octimot/StoryToolkitAI/ ) but ran into some problems on some Windows 10 machines.

The script crashes when it tries to load fusionscript.dll without throwing any exception (line 29 in DaVinciResolveScript.py)

To debug, I tried to simply open up a Python console and run:
Code: Select all
import imp
script_module = imp.load_dynamic("fusionscript", "C:\\Program Files\\Blackmagic Design\\Davinci Resolve\\fusionscript.dll")
But, the Python console quits without any error similar to what is happening in the tool scripts.
I've tried both Python 3.9.13 and 3.10.7, but the result was the same.

The file does exist at its path. Resolve Studio 18.0.4 is installed on said machine.

Any ideas on what it could be?
Last edited by Octavian Mot on Wed Oct 05, 2022 7:13 am, edited 1 time in total.
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostWed Oct 05, 2022 6:59 am

I tried to re-install Resolve on the machine, thus deleting all the dll files in the Program Files folder, but the problem still persists.

This is really weird since obviously the import works for most people and I'm trying to figure out what's causing it.

I'd be happy to read any suggestions.
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

barret

  • Posts: 2
  • Joined: Mon Oct 10, 2022 1:23 am
  • Real Name: Barret Xiong

Re: Problem loading fusionscript.dll via Python on Windows 1

PostMon Oct 10, 2022 1:27 am

The same situation occurred when utilizing fusionscript.dll. My python version is 3.8.10.

Looking for brilliant solutions to this problem. Appreciate it!
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostTue Oct 11, 2022 4:59 am

It seems that we're the only ones experiencing this.

Just for reference, what's your Windows and Resolve Studio version?
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

barret

  • Posts: 2
  • Joined: Mon Oct 10, 2022 1:23 am
  • Real Name: Barret Xiong

Re: Problem loading fusionscript.dll via Python on Windows 1

PostTue Oct 11, 2022 6:22 am

FYI, Windows 10 Enterprise 21H2 and Davinci Resolve 18.0B(Build 23)
Offline

sparkware

  • Posts: 2
  • Joined: Fri May 14, 2021 2:06 pm
  • Real Name: Kiyoon Kim

Re: Problem loading fusionscript.dll via Python on Windows 1

PostSat Oct 15, 2022 12:54 pm

I solved the issue by installing Python 3.10 on Windows.

Previously, I had Python 3.6 installed obviously to match the compatibility with Resolve.
Resolve 18 has a release note saying it detects any Python 3 version and it will be compatible with any.
Maybe with this change, there's an issue with previous installation or previous version of Python.

Even with the Resolve's Workspace > Console, Python3 wasn't detected before installing the new version.
Hope it helps.
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostFri Oct 21, 2022 12:20 pm

I uninstalled all Python versions from the computer and re-installed Python 3.9 using the installer available at https://www.python.org/downloads/windows/

Now it seems to work fine! :roll:
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

koryherber

  • Posts: 4
  • Joined: Mon May 15, 2023 4:04 pm
  • Real Name: Kory Herber

Re: Problem loading fusionscript.dll via Python on Windows 1

PostMon May 15, 2023 4:19 pm

Did you guys come with any resolution to this?

I've got what I think is a similar issue where I have built a GUI to run a few commands for setting up projects, exporting/rendering, etc. through the python API. I have two PC's I am trying to use this on that are both licensed for Resolve Studio.

When I run my script through my Python IDE (Spyder) it works perfectly fine for both PC's. However, when I create an exe using pyinstaller, the resulting .exe runs completely fine on PC A but does not work on PC B because it fails to connect to resolve API, ir returns None when trying to connect to Resolve.

I don't understand because PC B successfully connects to Resolve when running the script directly, but does not when running the .exe

I am confident the .exe works because I don't have issues with PC A, and I am confident that when running the .exe on PC B it just fails the initial connection to Resolve, returning None because of print/debug statements I've added.

What gives? is it some sort of path issue? why does it work via script but not exe? how do I fix it?
Windows firewall issue? is my exe not allowed to communicate over localhost for some reason?

PC A - has python 3.9 and runs from script
PC B - has python 3.10 and runs from script

exe built on/bundled python 3.9
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostMon May 15, 2023 7:54 pm

Haven't found a way to have multiple Python versions on the same Windows 10 machine unfortunately... except probably for bundling the .exe on Python 3.10...

My feeling is that Resolve chooses the latest Python version available on the machine and some sort of conflict arises when trying to connect to the API from an environment using an older version of Python.
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

koryherber

  • Posts: 4
  • Joined: Mon May 15, 2023 4:04 pm
  • Real Name: Kory Herber

Re: Problem loading fusionscript.dll via Python on Windows 1

PostMon May 15, 2023 8:48 pm

Thanks for the reply. Yeah, I think my next step is to try and deactivate and uninstall resolve, uninstall python 3.10 on PC B and then reinstall python 3.9, then reinstall and activate Resolve studio.

I am also wondering if Resolve didn't see any python installation when installing and something is off there...

Another odd problem I've run into is related to grabbing thumbnails of clips from the timeline. I know that Resolve needs to be in the color tab to use GetCurrentClipThumbnailImage() and there seems to also be some component of needing Resolve to be in the foreground of Windows (or at least not minimized).

I have a button in my GUI that when pressed, reads all markers in the timeline into a dict, then loops through each marker in this dict setting the current timecode (playhead position) to the frame of the marker, then calls GetCurrentClipThumbnailImage() once it gets the thumbnail data it add this to the dict and moves to the next one.

Most of the time, when running my script from the IDE, this works flawlessly and loops through all timeline markers, but not always, sometimes it switches to the color tab, sets the playhead to the position of the first marker, but then when it tries to get the thumbnail image, it never returns anything and times out (I programmed in a timeout loop while thumbnail returns None for 20 seconds.)

When it doesn't work, I usually close the project, reopen, then try the function/button in my GUI again and it works. This issue happens from both the .exe and when running the script directly from the IDE. I can't seem to nail down why it stalls out and doesn't return the thumbnail data for the times when it doesn't work.
Offline

koryherber

  • Posts: 4
  • Joined: Mon May 15, 2023 4:04 pm
  • Real Name: Kory Herber

Re: Problem loading fusionscript.dll via Python on Windows 1

PostTue May 16, 2023 7:06 pm

So I've sorted out my python issue with PC B by reinstalling my whole Anaconda distribution.

I've made a new discovery with the thumbnail issue that took a lot of testing to figure out some sort of causality.

I have discovered that when I launch Resolve, sometimes the project manager shows my projects with their thumbnails in the project manager window, which then when I open my project and use the API to get a thumbnail, it works as expected.

However, sometimes when I launch Resolve, it shows my projects but does not show any thumbnail images for the projects in the project manager window. This is when the API call to get the current clip thumbnail image fails. The project still functions as expected, playback and clips are ok, just the API can't get the thumbnail.

So, whatever process is used to get thumbnails seems to fail to launch or something when I launch Resolve, but only sometimes, because I can usually close and reopen Resolve until it launches with the thumbnails shown in the project manager. Still trying to figure out a way to ensure that whatever process this is, launches every time I launch Resolve.
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 7:51 am

You're not the only ones having the issue : viewtopic.php?f=21&t=194040
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 8:00 am

From the top of my head maybe this could be attempted (naive approach) :
1) Open a Terminal
2) Change all relevant env variables (PATH, etc.) to absolutely force that terminal to know only about Python 3.6 and no other Python version
3) Run DaVinci Resolve from that Terminal
...
4) Run your own Python script from the same Terminal or another terminal with similar Python settings.

In those conditions, would there be any way for DaVinci Resolve to load the wrong version of Python?

See also : https://stackoverflow.com/questions/51930730/change-default-python-version-for-command-prompt

=== EDIT ===

Please note that Windows 10 has an extra cache where it stores a copy of Python. That's why you can sometimes run python.exe from a Terminal where Python isn't even in the PATH env variable. You can disable this caching like this, it might save you headaches trying to figure out where Python comes from and which version it is : https://stackoverflow.com/questions/57485491/python-python3-executes-in-command-prompt-but-does-not-run-correctly/65520328#65520328
Then make sure that there's definitely no python.exe at C:\Users\MyUsername\AppData\Local\Microsoft\WindowsApps\python.exe

Type this command to identify where Windows finds python.exe at any time :
Code: Select all
where python
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 10:03 am

Following my previous post which was only offering leads, I did my own tests.

I present the results to you.

TL;DR: I haven't been able to force DaVinciResolve to use Python 3.6 on Windows when 3.12 is installed.


Here is what I tried :

1) (pre-requisite) disable python alias
- Press the "Windows" key, type "Settings", click on the Settings app. It opens.
- In searchbox "Find a setting", type "alias". Click "Manage app execution aliases"
- Disable every occurrence of "App installer" that refers to python.exe or python3.exe

2) (pre-requisite) delete python.exe cached by Windows
- You must have followed the steps above
- Open a command prompt as an administrator
- Delete cached python.exe :
(don't forget to replace MY_USER_NAME with your own user name)
Code: Select all
del C:\Users\MY_USER_NAME\AppData\Local\Microsoft\WindowsApps\python.exe

- Make sure everything worked :
Code: Select all
where python

The result must show the python installation from the PATH env variable.

3) Test your PATH
- Open a regular command prompt (not administrator)
- Check if Python appears in the PATH env variable, one or several times. For example :
Code: Select all
echo %PATH%
C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python36\;C:\WINDOWS\system32;C:\WINDOWS;C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python312\

There, in my system, you can see that it appears twice : Python 3.6 at the beginning and Python 3.12 at the end.
- Enter the following command to see which one the system picks up :
Code: Select all
python --version

- It should be python 3.6 as it's the first one in PATH (Windows looks at them in order)

4) Run DaVinciResolve from the same terminal, check what python it found
- That is to ensure that (hopefully) PATH will be the same for Resolve as it was for you a moment ago
- Open the Python console ( Workspace -> Console )
- Click "Py3"
- check what version Resolve picked up :
Code: Select all
    import platform
    print(platform.python_version())

- you can also check where it was loaded from:
Code: Select all
    import sys
    print(sys.path)

FAIL: It still displays python 3.12 despite 3.6 being before in the path.

5) Try to hide python 3.12 from DaVinci Resolve (you don't need to try, I tried for you):

Obviously, don't forget to revert your changes after you're done!
- This is merely a test to see if Resolve finds Python not by using the PATH but instead just by scanning the "python" folder.
- Go to this folder :
(don't forget to replace MY_USER_NAME with your own user name)
Code: Select all
C:\Users\MY_USER_NAME\AppData\Local\Programs\Python
   

- Notice how it contains both python312 and python36
- Rename folder "python312" to ".python312"
- Run DaVinci Resolve
- Open the Python console ( Workspace -> Console )
- Click "Py3"

FAIL: It says "No installation of python was found".
It seems to confirm that it uses the PATH otherwise it would not explicitly look for Python 3.12, it would pick up on Python 3.6 which is present in the same folder.

6) Try to entirely remove Python 3.12 from the PATH (you don't need to try, I tried for you):

Obviously, don't forget to revert your changes after you're done!
- In step 3 we saw that Python can appear several times in the path
- This step is an attempt to test if maybe DaVinci Resolve executable scans the PATH variable and picks up on every pythons present there, but then keeps the wrong one (the latest one)
- As a quick test I entirely overwrote PATH in my terminal :
- Open terminal
(don't forget to replace MY_USER_NAME with your own user name)
Code: Select all
SET PATH=C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\MY_USER_NAME\AppData\Local\Programs\Python\Python36\;C:\WINDOWS\system32;C:\WINDOWS;

- Run DaVinci Resolve from that terminal
- Open the Python console ( Workspace -> Console )
- Click "Py3"

FAIL: it still says that there's no python installed. It's still looking for python 3.12 (despite it not being in PATH) and fails to find it (because we hid it by renaming the folder)

Please note that if you "un-hide" python 3.12 binaries (by renaming the folder back) and then run this test again (i.e. only Python 3.6 in PATH, then start Resolve), you are now able to open the Console and click Py3.
Running the following Python commands demonstrate that even for DaVinci Resolve, only Python 3.6 is in PATH:
Code: Select all
import os
print(os.environ["PATH"])

It reinforces the mystery of how it finds the Python executables.

7) Try to hide Python 3.12 by sabotaging py.exe and the registry
(you don't need to try, I tried for you)


Obviously, don't forget to revert your changes after you're done!
- Rename the Python launcher, which helps programs finding your Python installation :
Code: Select all
ren C:\Windows\py.exe .py.exe

- Open the registry (regedit.exe) as the user who installed Python 3.12 (probably not admin)
- Go to
Code: Select all
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore

- There, rename subfolder 3.12 to whatever temporary bogus name.
- Start DaVinci Resolve
- Open the Python console ( Workspace -> Console )
- Click "Py3"
Code: Select all
import sys
print(sys.path)

- Still 3.12. How???!!!????


8) With a Python virtual environment
- Note that for this test I reverted everything before. Python 3.12 is installed and not hidden, and in the PATH. But I was hoping that the virtual env was the perfect solution.
- Open a Powershell terminal
- Run this command (create virtual env with Python 3.6) :
Code: Select all
C:\Users\YOUR_USER_NAME\AppData\Local\Programs\Python\Python36\python.exe -m venv venv

(more info here )
- Run this command (activate virtual env)
Code: Select all
venv\Scripts\activate

- Run Resolve from the virtual env (the & is for running it in a non-blocking way)
Code: Select all
& 'C:\Program Files\Blackmagic Design\DaVinci Resolve\Resolve.exe'

- Open the Python console ( Workspace -> Console )
- Click "Py3"
Code: Select all
import sys
print(sys.path)

- Still 3.12. How???!!!????


CONCLUSION:
I'm at the end of my wits. I couldn't find how to force DaVinci Resolve to use a specific Python installation. If only I could find out how it lists the installed versions???
Last edited by JeanCall on Thu Dec 28, 2023 12:10 pm, edited 3 times in total.
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 10:25 am

@JeanCall

I really appreciate you taking the time to figure this out!

As we can see, it's not obvious how Resolve is choosing the python version it uses. From what I can tell it always picks the latest version installed on a machine. For eg. if 3.9, 3.10 and 3.11 is installed, it's going to choose 3.11. Once that is uninstalled, it's going for 3.10 and so on.

Unfortunately, there are many ways in which this choice would be made, besides what you already tried out:
  • Scanning installation directories for Python executables (like those under C:\Users\[Username]\AppData\Local\Programs\Python\ or C:\PythonXX\)
  • Querying Windows Installer Data for eg. via WMI
  • Using py.exe to invoke the latest python version
  • Registry entries
  • etc.

So, I think for a Python developer used with PATH variables or sys.executable paths (like myself), the method might not be quite obvious, unless you're really deep into OS-specific programming too...

Nevertheless, if you have time to dig these further and reverse engineer, by all means, let's try to figure it out! :D

But, it would be great if BM would solve this mystery and provide an answer, so that we can allow users with more complex environments to use our tools...
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 11:20 am

Octavian Mot wrote:@JeanCall
besides what you already tried out:
  • Scanning installation directories for Python executables (like those under C:\Users\[Username]\AppData\Local\Programs\Python\ or C:\PythonXX\)
  • Querying Windows Installer Data for eg. via WMI
  • Using py.exe to invoke the latest python version
  • Registry entries
  • etc.


I've updated my post with my tests regarding the Registry and py.exe

Someone on stack overflow suggested an alternative approach, which I will try :

As for making your program run with a different python version, you'll have to create a virtual environment with the version you want and activate it before starting your application. Activating an environment modifies the path and environment variables to point to a specific Python version and packages.
Resources:
- https://realpython.com/python-virtual-e ... -a-primer/
- https://stackoverflow.com/questions/153 ... virtualenv


EDIT: I tried (see update in previous message)
Last edited by JeanCall on Thu Dec 28, 2023 12:10 pm, edited 1 time in total.
Offline

Octavian Mot

  • Posts: 286
  • Joined: Mon Aug 25, 2014 2:42 pm
  • Location: Germany

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 11:43 am

This is great work @JeanCall

Could you maybe try running this in a python script from resolve when you're doing the tests?

Code: Select all
# save this as debug_sys.py and run it from DaVinci Resolve
import sys
import os

# use absolute path here
debug_folder = 'C:\\\\path\\to\\where\\to\\save\\debug\\files'

# save this as debug_env.py and run it from DaVinci Resolve
report_file = os.path.join(debug_folder, 'env_report.txt')
with open('env_report.txt', 'w') as file:
    for key, value in os.environ.items():
        file.write(f"{key}: {value}\n")

sys_report_file = os.path.join(debug_folder, 'sys_report.txt')
with open(sys_report_file, 'w') as file:
    file.write(f"Executable: {sys.executable}\n")
    file.write(f"Version: {sys.version}\n")
    file.write(f"Path: {sys.path}\n")


This might help solve some of the environment related mysteries...
Trying to keep it together at mots.us
Taming AI for filmmaking at StoryToolkit.ai
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 12:21 pm

Well I don't need all this machinery to give you the info.
Basically, every time I wrote "it's still Python 3.12" I got it from doing a subset of what you suggested.

A warning : I can paste the data here, but it willl only illustrate the basic config, i.e. when I don't try to force Python 3.6, i.e. when 3.12 is in PATH and so on. I'm not going to re-do it for every attempt I mentionned. :-D

sys.version:
Code: Select all
3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]

sys.path:
Code: Select all
['C:\\Program Files\\Blackmagic Design\\DaVinci Resolve', 'C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python312\\python312.zip', 'C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python312\\DLLs', 'C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python312\\Lib', 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve', 'C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python312', 'C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages']


sys.executable:
Code: Select all
C:\Program Files\Blackmagic Design\DaVinci Resolve\Resolve.exe


os.environ:
Code: Select all
environ({'ALLUSERSPROFILE': 'C:\\ProgramData', 'APPDATA': 'C:\\Users\\Lab\\AppData\\Roaming', 'CHOCOLATEYINSTALL': 'C:\\ProgramData\\chocolatey', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files', 'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'XXXXXXXXX', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'DRIVERDATA': 'C:\\Windows\\System32\\Drivers\\DriverData', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Users\\Lab', 'JAVA_HOME': 'C:\\Program Files\\Java\\jdk-17.0.2', 'LOCALAPPDATA': 'C:\\Users\\Lab\\AppData\\Local', 'LOGONSERVER': '\\\\XXXXXXX', 'NUMBER_OF_PROCESSORS': '12', 'NVM_SYMLINK': 'C:\\Program Files\\nodejs', 'ONEDRIVE': 'C:\\Users\\Lab\\OneDrive', 'OS': 'Windows_NT', 'PATH': 'C:\\Users\\Lab\\venv\\Scripts;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Java\\jdk-17.0.2\\bin;C:\\Program Files\\CMake\\bin;C:\\Strawberry\\c\\bin;C:\\Strawberry\\perl\\site\\bin;C:\\Strawberry\\perl\\bin;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\WireGuard\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\nodejs\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\;C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python36\\;C:\\Users\\Lab\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Lab\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.CPL', 'POWERSHELL_DISTRIBUTION_CHANNEL': 'MSI:Windows 10 Enterprise', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 158 Stepping 10, GenuineIntel', 'PROCESSOR_LEVEL': '6', 'PROCESSOR_REVISION': '9e0a', 'PROGRAMDATA': 'C:\\ProgramData', 'PROGRAMFILES': 'C:\\Program Files', 'PROGRAMFILES(X86)': 'C:\\Program Files (x86)', 'PROGRAMW6432': 'C:\\Program Files', 'PSMODULEPATH': 'C:\\Users\\Lab\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules', 'PUBLIC': 'C:\\Users\\Public', 'SESSIONNAME': 'Console', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\\Users\\Lab\\AppData\\Local\\Temp', 'TMP': 'C:\\Users\\Lab\\AppData\\Local\\Temp', 'USERDOMAIN': 'XXXXXXX', 'USERDOMAIN_ROAMINGPROFILE': 'XXXXXXX', 'USERNAME': 'Lab', 'USERPROFILE': 'C:\\Users\\Lab', 'VIRTUAL_ENV': 'C:\\Users\\Lab\\venv', 'VS140COMNTOOLS': 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\', 'WINDIR': 'C:\\WINDOWS', 'ZES_ENABLE_SYSMAN': '1', '_OLD_VIRTUAL_PATH': 'C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Java\\jdk-17.0.2\\bin;C:\\Program Files\\CMake\\bin;C:\\Strawberry\\c\\bin;C:\\Strawberry\\perl\\site\\bin;C:\\Strawberry\\perl\\bin;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs;C:\\Program Files\\WireGuard\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\nodejs\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\;C:\\Users\\Lab\\AppData\\Local\\Programs\\Python\\Python36\\;C:\\Users\\Lab\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Lab\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;', 'QT_MAC_WANTS_LAYER': '1', 'PXR_MTLX_STDLIB_SEARCH_PATHS': 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\Plugins\\USD\\MaterialX\\libraries'})
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Dec 28, 2023 12:36 pm

I give up for now.

My workaround will be this:
1. create a local Windows user just for video editing,
2. sign-in as that user,
3. install only Python 3.6 into that user profile (and make sure no other versions are installed in that profile.
Check that in "add or remove programs" and/or with the python launcher (py.exe)
4. Run Resolve, open the Console, check the version there (as explained before). It's 3.6. Success. F*** it.

Code: Select all
Py3> import sys
Py3> print(sys.version)
3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Py3> fusion = resolve.Fusion()
Py3> projectManager = resolve.GetProjectManager()
Py3> print(projectManager)
ProjectManager (0x00007FF71195A6E0) [App: 'Resolve' on 127.0.0.1, UUID: 705f9ff0-d1d5-4d28-bd39-461ccb36e095]
Py3> print(resolve)
Resolve (0x00007FF71195A6B0) [App: 'Resolve' on 127.0.0.1, UUID: 705f9ff0-d1d5-4d28-bd39-461ccb36e095]
Py3> projectManager.CreateProject("Hello World")
Offline

michaelZ

  • Posts: 3
  • Joined: Tue Aug 03, 2021 2:13 pm
  • Real Name: Michael Zangrando

Re: Problem loading fusionscript.dll via Python on Windows 1

PostThu Mar 28, 2024 1:33 pm

Here's my experience with using DaVinciResolve scripting on Windows 10/11, I hope it may help someone.

1. it works fine with Python 3.9, Python 3.10 or Python 3.11. No need to stick with 3.6

2. DaVinci Resolve will automatically use the highest version of Python that you have installed on your system. Your own standalone script also needs to run that version of Python or else the import will silently fail.

3. DaVinci Resolve finds the highest version of Python by looking in the registry inside HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore

4. DaVinciResolveScript won't work with Python 3.12 because the "imp" module has been removed. Blackmagic, please fix this by using the importlib module instead.

5. The only way I got scripting to work with Python 3.12 installed on my system is to go to the registry and rename the "folder" HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.12 to, say, HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.12. DaVinci will then revert to using 3.11

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 5 guests