Netgen DLL problem on fresh Windows 11 VM

Hello,

I’ve just run a fresh Windows 11 VM, installed python 3.12.4 from Microsoft Store,
installed netgen with pip install --upgrade ngsolve and added
C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts
to the PATH environment variable, but netgen cannot start because of the following error:

C:\Users\User>netgen
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\netgen.exe\__main__.py", line 4, in <module>
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgen\__init__.py", line 98, in <module>
    from pyngcore import Timer
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyngcore\__init__.py", line 1, in <module>
    from .pyngcore import *
ImportError: DLL load failed while importing pyngcore: A dynamic link library (DLL) initialization routine failed.

Is there something I am missing?

Thanks,
Stenio

Hi,

Do you have any news about this issue? Something is definitively not working as expected if the software cannot work on a fresh virtual machine, don’t you agree?

This is not a real fix but as far as I know the python from the microsoft store has some weird installation behaviour… Does it work if python is installed from the python website?

I’ve just tried with a new VM:

  1. installed python 3.12.4 from www.python.org

Screenshot 2024-08-01 160504

  1. from a non administrative prompt
    pip install --upgrade ngsolve

  2. and then
    netgen

Unfortunatelly I got the same error. :weary:

Does it work if python is installed from the python website?

No, it doesn’t. Please, see my previous post.

Thanks

I tried also with python 3.13 and 3.11, but I got the same error.
Seems to me that there is a problem on the package pyngcore.
This is the free VM that I used: Oracle Virtual Box.

Ah I think I could just reproduce the problem. Can you try installing vcruntime?

Hi Christopher, sorry for the delay. The virtual machine comes with the runtime already installed:

Thanks,
Stenio

can you load the pyngcore library into this dependency walker to see which libs it is missing?

https://lucasg.github.io/Dependencies/

Sure. Here it is:

python should be fine, this should be there at runtime. Can you find where ngcore.dll was installed to from pip? And also the path to the pyngcore.dll

Hi Christopher,

ngcore.dll is here:

C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgen

I can’t find pyngcore.dll. I have pyngcore.cp312-win_amd64.pyd in C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyngcore instead.

I fixed the missing modules adding their directories to %PATH%:

but still I get:

C:\Users\User>netgen Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts\netgen.exe\__main__.py", line 4, in <module> File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\netgen\__init__.py", line 98, in <module> from pyngcore import Timer File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyngcore\__init__.py", line 1, in <module> from .pyngcore import * ImportError: DLL load failed while importing pyngcore: A dynamic link library (DLL) initialization routine failed.

I made some progress setting the environment variable PYTHONPATH:

C:\Users\User>echo %PYTHONPATH%
C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyngcore;C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\netgen;C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts;

C:\Users\User>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\User\AppData\Local\Programs\Python\Python312\;C:\Users\User\AppData\Local\Programs\Python\Launcher\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\netgen;C:\Users\User\AppData\Local\Programs\Python\Python312;

C:\Users\User>netgen
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Scripts\netgen.exe\__main__.py", line 4, in <module>
    spec = importlib.util.spec_from_file_location(os.path.basename(f), os.path.abspath(f))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\netgen\__init__.py", line 98, in <module>
    from pyngcore import Timer
ImportError: DLL load failed while importing pyngcore: A dynamic link library (DLL) initialization routine failed.

I’ve reinstalled python 3.12 and the path now are

C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyngcore and
C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\netgen

The result is the same.

Perhaps the real problem is the absence of the pyngcore.dll file.