19 October 2021 at 08:36 #20656
I am using python interpreter to program simulations. Now I want to realize a function that after one simulation end (I will define some condition to determine the simulation is end), and change force field to do simulation again and agian. My plan is to program it in main loop, and run directly in python interpreter. But I found that I cannot import Sofa.Gui, it said
[ERROR] [SofaRuntime] ImportError: DLL load failed: The specified procedure could not be found.
I am using 21.06 version in windows.
I check the interpreter path in my pycharm
I tried to run windows cmd before, it works fine at the beginning, but when I modify some in Pycharm, it does not work then. I don’t know why actually or I missed something.
Thanks for your help!
YUAN19 October 2021 at 09:46 #20660
Oh, the image link broke, the path included site-packages in SofaPython3 and other DLLs or Lib of python. I can import Sofa.Simulation and other components in this package except Gui and I can use runSofa, too.
by the way how to actually put an image, I actually put the image in my goole drive and share the link in this post, but it breaks21 October 2021 at 21:30 #20681
I was going to say from your first post, the SOFA_ROOT and PYTHONPACKAGE environment variables would be wrongly set.
You mean to load an image on the forum ? You must give a link to the image itself not the sharing google link.
Is this topic solved though? Shall we close it?
Hugo22 October 2021 at 10:05 #20691
Unfortunately, I did not solve the problem. I actually don’t understand what you mean PYTHONPACKAGE. Is PYTHONPACKAGE a system environmental variable or you mean python package related variable like PYTHON_ROOT or PYTHONPATH. Anyway, I did try to create variable called PYTHONPACKAGE linking to SofaPython3 site-packages and python site-packages. But it does not work.
I want to share the variables I set to make sure if there is some problems.
PYTHON_ROOT: C:\Users\user\AppData\Local\Programs\Python\Python37 PYTHONPATH: C:\SOFA\SOFA_v21.06.01_Win64\plugins\SofaPython3\lib\python3\site-packages SOFA_ROOT: C:\SOFA\SOFA_v21.06.01_Win64 Path: %PYTHON_ROOT%;%PYTHON_ROOT%\DLLs;%PYTHON_ROOT%\Lib;%SOFA_ROOT%\bin;%SOFA_ROOT%;C:\Users\user\AppData\Local\Programs\Python\Python37\Scripts
With above settings, I can successfully run runSofa with Sofapython3 in cmd which means sofa_root\bin is successfully set.
C:\Users\user>runSofa [INFO] [runSofa] PluginRepository paths = C:/SOFA/SOFA_v21.06.01_Win64/bin;C:/SOFA/SOFA_v21.06.01_Win64/plugins;C:/SOFA/SOFA_v21.06.01_Win64/bin [INFO] [runSofa] DataRepository paths = C:/SOFA/SOFA_v21.06.01_Win64/share/sofa;C:/SOFA/SOFA_v21.06.01_Win64/share/sofa/examples;C:/SOFA/SOFA_v21.06.01_Win64/share/sofa;C:/SOFA/SOFA_v21.06.01_Win64/share/sofa/examples [INFO] [runSofa] GuiDataRepository paths = C:/SOFA/SOFA_v21.06.01_Win64/share/sofa/gui/runSofa;C:/SOFA/SOFA_v21.06.01_Win64/share/sofa/gui/qt;C:/SOFA/SOFA_v21.06.01_Win64/share/sofa/gui/qt [INFO] [runSofa] Loading automatically plugin list in C:/SOFA/SOFA_v21.06.01_Win64/bin/plugin_list.conf [INFO] [SofaPython3] Initializing with python version 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] [INFO] [SofaPython3] Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files. [INFO] [SofaPython3] Intializing python [INFO] [PluginManager] Loaded plugin: C:/SOFA/SOFA_v21.06.01_Win64/bin/SofaPython3.dll [INFO] [SofaPython3] Added 'C:/SOFA/SOFA_v21.06.01_Win64/plugins/SofaPython3/lib/python3/site-packages' to sys.path
I also try import other module in C:\SOFA\SOFA_v21.06.01_Win64\plugins\SofaPython3\lib\python3\site-packages, they all can be imported successfully except Sofa.Gui.
C:\Users\user>python Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Sofa >>> import SofaRuntime >>> import SofaTypes >>> import splib >>> import Sofa.Components >>> import Sofa.Core >>> import Sofa.Helper >>> import Sofa.Simulation >>> import Sofa.SofaDeformable >>> import Sofa.SofaGL >>> import Sofa.Types >>> import Sofa.Gui [ERROR] [SofaRuntime] ImportError: DLL load failed: The specified procedure could not be found. Traceback (most recent call last): File "<stdin>", line 1, in <module> >>>
Do you have any suggestions?
Thank you very very much for your help!!!
YUAN2 November 2021 at 19:25 #207254 November 2021 at 16:55 #20739GuillaumeKeymaster
Your environment looks good: PATH and PYTHONPATH are OK (PYTHONPACKAGE is useless, I think Hugo wanted to say PYTHONPATH).
The next step for you is to investigate which dependency of
Sofa.Guiis not found, leading to the very unclear Windows error “DLL load failed” (thank you Windows).
To do that, I suggest you download the latest release of lucasg/Dependencies.
Unzip it on your computer and run the executable “DependenciesGui.exe”.
In DependenciesGui, open the file
You should get a better idea of what is not found in the dependencies (upper-left part of DependenciesGui).
Hope that helps!
Guillaume.10 November 2021 at 20:50 #2077421 December 2021 at 06:40 #21187
- You must be logged in to reply to this topic.