SOLVED: DLL Load Failed - QtCore

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Friel20
Posts: 5
Joined: Mon Aug 10, 2020 10:52 am

SOLVED: DLL Load Failed - QtCore

Post by Friel20 »

Hello,

I have exhausted all avenues in trying to solve this error. I have seen it has occurred for many people online and having tried all their 'fixes' I am now posting here to see if anyone can offer anything new.

I am trying to interface with FreeCAD 0.18 using Python in Visual Studio via Anaconda 3, python version 3.6.10

The error arises when calling 'from PySide2.QtCore import *' through FreeCAD's QtCore.py file. It reads DLL load failed: The specified procedure could not be found.

In my attempts to solves this I have:

1. checked PySide2 and shiboken2 are the same version - they are 5.15
2. Added Anaconda as PATH variable
3. uninstalled and reinstalled python environments
4. conda installed PySide2 and pip installed PySide2

Firstly, what does this mean exactly? And what can I do to fix it?

I am new to FreeCAD and its API so any help/advice is greatly appreciated.
Last edited by Friel20 on Fri Oct 02, 2020 11:25 am, edited 2 times in total.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: DLL Load Failed - QtCore

Post by wmayer »

I am trying to interface with FreeCAD 0.18 using Python in Visual Studio via Anaconda 3, python version 3.6.10
Does your FreeCAD 0.18 version also use Python 3.6?
The error arises when calling 'from PySide2.QtCore import *' through FreeCAD's QtCore.py file. It reads DLL load failed: The specified procedure could not be found.
Since you have Visual Studio installed you should try to run FreeCAD in the debugger. Then in Visual Studio activate the Output window and clear its content.
Enter from PySide2.QtCore import * into FreeCAD's Python console. Now check the content of the Output window of Visual Studio. It should print which dlls are tried to be loaded and from which location.
DLL load failed: The specified procedure could not be found.
This error usually means that a dll of the requested name was found but it's binary incompatible.
1. checked PySide2 and shiboken2 are the same version - they are 5.15
2. Added Anaconda as PATH variable
3. uninstalled and reinstalled python environments
3. conda installed PySide2 and pip installed PySide2
The FreeCAD installer includes the Python environment and all extension modules the application needs. There is actually no need to install further libraries from somewhere else.

You said PySide2 and shiboken version is 5.15. So I assume that the linked Qt version is 5.12 or newer. However, the Qt version FreeCAD 0.18 is linked to is probably 5.6 (check in FreeCAD with Help > About > Copy to clipboard)
Friel20
Posts: 5
Joined: Mon Aug 10, 2020 10:52 am

Re: DLL Load Failed - QtCore

Post by Friel20 »

Many thanks for you response! I have answered these as best I can...
Does your FreeCAD 0.18 version also use Python 3.6?
Yes I have changed Anaconda python from 3.8 to 3.6 to match FreeCAD
Since you have Visual Studio installed you should try to run FreeCAD in the debugger. Then in Visual Studio activate the Output window and clear its content.
The resulting output:
From what I can gather it's failing in QtCore.py
DLL load failed: The specified procedure could not be found.
Stack trace:
> File "C:\Program Files\FreeCAD 0.18\Ext\PySide\QtCore.py", line 1, in <module>
> from PySide2.QtCore import *
> File "C:\Program Files\FreeCAD 0.18\Mod\Fem\femtools\ccxtools.py", line 36, in <module>
> from PySide import QtCore
> File "C:\Program Files\FreeCAD 0.18\Mod\Fem\femobjects\_FemSolverCalculix.py", line 32, in <module>
> from femtools import ccxtools
> File "C:\Program Files\FreeCAD 0.18\Mod\Fem\ObjectsFem.py", line 446, in makeSolverCalculixCcxTools
> from femobjects import _FemSolverCalculix
> File "mypathtopyfile", line 140, in <module>
> solver_obj = objFEM.makeSolverCalculixCcxTools(FC.ActiveDocument)
Loaded 'PySide.QtCore'
Loaded 'femtools.ccxtools'
Loaded 'femobjects._FemSolverCalculix'
Loaded 'ObjectsFem'
Loaded '__main__'
Loaded 'runpy'
The FreeCAD installer includes the Python environment and all extension modules the application needs. There is actually no need to install further libraries from somewhere else.
Correct - without installing it will still arrive at the same error.
You said PySide2 and shiboken version is 5.15. So I assume that the linked Qt version is 5.12 or newer. However, the Qt version FreeCAD 0.18 is linked to is probably 5.6 (check in FreeCAD with Help > About > Copy to clipboard)
The Qt version is 5.6.2. Does this need updated to match PySide2 and shiboken2 version? Or those update to match Qt version 5.6?
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: DLL Load Failed - QtCore

Post by wmayer »

The resulting output:
I didn't want the output of FreeCAD but rather that of VS when you run FreeCAD from within it.
The Qt version is 5.6.2
Is this the version FreeCAD uses?

And can you also figure out which Qt version PySide2 5.15 is linked to? If for some reason you cannot figure out this with VS then you can also use the tool ProcessExporer. Therefore start the external Python interpreter from anaconda and try to load QtCore. Now open the ProcessExplorer and select python.exe. In a separate window you should see all loaded dlls -- among them Qt5Core.dll. In the properties dialog to this file you should see the Qt version number.
Friel20
Posts: 5
Joined: Mon Aug 10, 2020 10:52 am

Re: DLL Load Failed - QtCore

Post by Friel20 »

I didn't want the output of FreeCAD but rather that of VS when you run FreeCAD from within it.
VS does not show any output when I put that line in to FreeCAD's python console.
The Qt version is 5.6.2
Is this the version FreeCAD uses?
This is the version shown from Help > About > Copy to clipboard in FreeCAD.
And can you also figure out which Qt version PySide2 5.15 is linked to?
This version is 5.9.7.0 from VS and Process Explorer.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: DLL Load Failed - QtCore

Post by wmayer »

VS does not show any output when I put that line in to FreeCAD's python console.
With VS you must load the FreeCAD.exe and press F5 or alternatively run FreeCAD and in VS use Debug > Attach to process. Important is that FreeCAD runs with a debugger.
This version is 5.9.7.0 from VS and Process Explorer.
OK, then the different Qt versions is the problem.
Friel20
Posts: 5
Joined: Mon Aug 10, 2020 10:52 am

Re: DLL Load Failed - QtCore

Post by Friel20 »

With VS you must load the FreeCAD.exe and press F5 or alternatively run FreeCAD and in VS use Debug > Attach to process. Important is that FreeCAD runs with a debugger.
I have tried this and still not receiving any output window messages in Visual Studio after putting from PySide2.QtCore import * into FreeCAD's python console.
Would this imply VS and FreeCAD are not linked?
OK, then the different Qt versions is the problem.
What can I do to resolve this. Have tried conda install qt=5.6 with no success.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: DLL Load Failed - QtCore

Post by wmayer »

What can I do to resolve this. Have tried conda install qt=5.6 with no success.
You should try with FreeCAD v0.19 then because this uses a newer Qt version and if you are lucky you will find a PySide2 version that uses the same Qt version.
Friel20
Posts: 5
Joined: Mon Aug 10, 2020 10:52 am

Re: DLL Load Failed - QtCore

Post by Friel20 »

To close out this post I want to share my fix for other users.

To successfully access and use FreeCAD API in Visual Studio (Community Version) 2019 I created the python 3.6 environment as a conda environment through VS's Python Environment's 'Add Environment' functionality. This bypassed the issues I faced using Anaconda and it's installation of python 3.6 which did not allow communication with FreeCAD in my instance.

Hope this is of use to anyone else facing this issue.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: SOLVED: DLL Load Failed - QtCore

Post by Kunda1 »

This needs to be added to the wiki
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply