FreeCADCmd.exe --run-test 0 failure with DLL

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
CandL
Posts: 85
Joined: Thu Oct 29, 2020 6:41 pm

FreeCADCmd.exe --run-test 0 failure with DLL

Post by CandL »

Win 11 (x64)
Visual Studio 2022
LibPack-OCC76-V2

Removed prior Python install in case it was an issue, relatively clean PATH

Code: Select all

where python
C:\Users\***\github\LibPack-OCC76-V2\bin\python.exe
C:\Users\***\AppData\Local\Microsoft\WindowsApps\python.exe

Built FreeCad locally ... ran cmake-gui in a new dir (out of source build), asked for the MSVS 2022 build (set x64) config & generated... Opened MSVS toggled to Release build. After whirs and grinds it created : FreeCadmd.exe

set PYTHONHOME=C:\Users\****\github\LibPack-OCC76-V2\bin

Verified from CMAKE ... Shiboken2_DIR = C:/Users/****/github/FreeCAD-LibPack/LibPack-OCC76-V2/lib/cmake/Shiboken2-5.15.0

Verified C:\Users\****\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\TestAddonManagerApp/py size is 3KB

Code: Select all

FreeCADCmd.exe --run-test 0
Yielded ....

Code: Select all

======================================================================
ERROR: TestAddonManagerApp (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: TestAddonManagerApp
Traceback (most recent call last):
  File "C:\Users\***\github\LibPack-OCC76-V2\bin\lib\unittest\loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "C:\Users\***\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\TestAddonManagerApp.py", line 26, in <module>
    from AddonManagerTest.app.test_utilities import (
  File "C:\Users\***\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\AddonManagerTest\app\test_utilities.py", line 29, in <module>
    from Addon import Addon
  File "C:\Users\***\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\Addon.py", line 30, in <module>
    from addonmanager_macro import Macro
  File "C:\Users\***\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\addonmanager_macro.py", line 34, in <module>
    import NetworkManager
  File "C:\Users\***\github\FreeCAD\FreeCad_build_new\Mod\AddonManager\NetworkManager.py", line 70, in <module>
    from PySide2 import QtCore
  File "C:\Users\***\github\LibPack-OCC76-V2\bin\lib\site-packages\PySide2\__init__.py", line 107, in <module>
    _setupQtDirectories()
  File "C:\Users\***\github\LibPack-OCC76-V2\bin\lib\site-packages\PySide2\__init__.py", line 58, in _setupQtDirectories
    import shiboken2
  File "C:\Users\***\github\LibPack-OCC76-V2\bin\lib\site-packages\shiboken2\__init__.py", line 27, in <module>
    from .shiboken2 import *
ImportError: DLL load failed while importing shiboken2: The specified module could not be found.
plus 15 similar errors.

Ideas?

Thanks
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: FreeCADCmd.exe --run-test 0 failure with DLL

Post by adrianinsaval »

CandL wrote: Mon Aug 01, 2022 7:18 pm set PYTHONHOME=C:\Users\****\github\LibPack-OCC76-V2\bin

Verified from CMAKE ... Shiboken2_DIR = C:/Users/****/github/FreeCAD-LibPack/LibPack-OCC76-V2/lib/cmake/Shiboken2-5.15.0
I have no experience building on windows but your paths are different here, are you sure PYTHONHOME is correctly set?
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: FreeCADCmd.exe --run-test 0 failure with DLL

Post by GeneFC »

CandL wrote: Mon Aug 01, 2022 7:18 pm Ideas?
Not sure what you are doing or why, but I just tried the same test on a freshly built version using the same Libpack. I added absolutely NO extra instructions such as PYTHONHOME. I don't know why you would do that since FreeCAD automatically finds the correct dependencies when compiled with the Libpack.

Various failure from some of the the tests, but the testing process worked fine.

Gene
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCADCmd.exe --run-test 0 failure with DLL

Post by wmayer »

relatively clean PATH
ImportError: DLL load failed while importing shiboken2: The specified module could not be found.
Make sure that the LibPack's bin directory is part of your path.

Code: Select all

set PATH=C:\Users\****\github\FreeCAD-LibPack\LibPack-OCC76-V2\bin;%PATH%
I guess that the used Python version is >= 3.8 then you also have to set this environment variable:

Code: Select all

set FREECAD_LIBPACK_BIN=C:\Users\****\github\FreeCAD-LibPack\LibPack-OCC76-V2\bin
This is important because for security reasons Python no longer considers the PATH environment variable when trying to load a .pyd file.
CandL
Posts: 85
Joined: Thu Oct 29, 2020 6:41 pm

Re: FreeCADCmd.exe --run-test 0 failure with DLL

Post by CandL »

Thank you folks, seems to be working now... wmayer comments triggered me to to validate the version of Python... and it is Python 3.8.10.

But this further had me thinking ... move the env vars up in the PATH chain.

Doing this resolved the issue.

Now I wonder, what did I just break? Gotta love computers .... sigh.

Thanks again.
Post Reply