ImportError: DLL load failed while importing simulator

Hello,
I’m a beginner user of OpenGeoSys, but I think there is a problem with the binaries distributed by PIP packages:

Folowing the procedure in Your first OGS run in 5 minutes with “Option 1: Python”, I set everything ok with pip install ogstools[ogs], but running the example gives the error:

❯ python .\Linear_Disc_with_hole.py
Simulation: disc_with_hole.prj       
Status: terminated with error code 1.
Last 10 line of the log:
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:\...\OGS\.venv\Scripts\ogs.exe\__main__.py", line 7, in <module>
  File "C:\...\OGS\.venv\Lib\site-packages\ogs\_internal\provide_ogs_cli_tools_via_wheel.py", line 84, in ogs
    raise SystemExit(ogs_with_args(sys.argv))
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\OGS\.venv\Lib\site-packages\ogs\_internal\provide_ogs_cli_tools_via_wheel.py", line 88, in ogs_with_args
    import ogs.simulator as sim
ImportError: DLL load failed while importing simulator: Não foi possível encontrar o módulo especificado.

Traceback (most recent call last):
  File "C:\...\OGS\Linear_Disc_with_hole.py", line 224, in <module>
    model.run_model(logfile=f"{out_dir}/out.txt", args=f"-o {out_dir}")
  File "C:\...\OGS\.venv\Lib\site-packages\ogstools\ogs6py\project.py", line 914, in run_model
    self._failed_run_print_log_tail(write_logs)
  File "C:\...\OGS\.venv\Lib\site-packages\ogstools\ogs6py\project.py", line 764, in _failed_run_print_log_tail        
    raise RuntimeError(msg)
RuntimeError: OGS execution was not successful.

However, by downloading the binary and putting the /bin folder on the PATH after activating the environment, it runs ok.

So, I think the issue is with the binary distributed with PIP.

I also searched for this problem before creating this topic, and saw post “1667” (sorry, I can’t link because I’m new user and the site does not allow me…)

1 Like

Hi Diogo,

it’s really bad that our first example does not run. Thank you for reporting this.

You mentioned Import ogs.callbacks gives "Import error".
Could you try if the fix of that resolves the problem for you, please? See my last response from 5 minutes ago: Import ogs.callbacks gives "Import error" - #5 by chleh

We’ll try to reproduce the problem. Btw.: What are your PATH, PYTHONPATH, Python version in the virtual environment? Which distribution do you use (anaconda/minicondy/python.org/…)?

Best regards,
Christoph

I encounter exactly the same problem. Everything went well with,
import ogstools as ot
model = ot.Project(input_file=“xx.prj”, output_file=“xx.prj”)
model.replace_text(‘…’)
model.write_input()
then when I run,
model.run_model(logfile=“out.txt”),
The exactly same error came out.
I am using,

  • OS: Windows 10
  • Python distribution: Anaconda
  • Python version: 3.11.7
  • OGS version: 6.5.6 (installed via pip install ogs)
  • Environment: base conda environment

The OGS package is installed in
C:\Users\Anwender\anaconda3\Lib\site-packages\ogs.

PATH: C:\Users\Anwender\anaconda3;
C:\Users\Anwender\anaconda3\Library\mingw-w64\bin;
C:\Users\Anwender\anaconda3\Library\usr\bin;
C:\Users\Anwender\anaconda3\Library\bin;
C:\Users\Anwender\anaconda3\Scripts;
C:\Users\Anwender\anaconda3\bin;
C:\Users\Anwender\anaconda3\condabin;
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0;
C:\Windows\System32\OpenSSH;
C:\Program Files\Plaxis\PLAXIS 2D\python\plxpy;
C:\Program Files (x86)\Windows Live\Shared;
C:\Program Files\dotnet;
C:\Program Files\Seequent\PLAXIS 2D 2023.1\python\plxpy;
C:\Users\Anwender\AppData\Local\Microsoft\WindowsApps;
C:\Users\Anwender\AppData\Local\Programs\Microsoft VS Code\bin

PYTHONPATH: not set

Hey, I solved the problem, by downloading the older version
pip install ogs==6.5.2,
Because this is the version that my another computer is working.
Hope the ogs development team can solve the issue in OGS version 6.5.6 with the simulator

I tried the 6.5.6 pip package on Python 3.11 as well and for me it worked. Maybe the Conda environment interferes? Please note that we also have native Conda packages of ogs and ogstools: