Beginners > Installation questions

PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'

(1/2) > >>

Leonardo:
Hi there,
I've been using PHREEQC COM for ~8 years now, from Python, on different computers. But most recently I changed my laptop and ran my previous scripts to find an error as follows:

--- Quote ---Traceback (most recent call last):

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:84 in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)

com_error: (-2147221021, 'Operation unavailable', None, None)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\mp4 geochemical assessment\4-working\5-modelling\frim\untitled0.py:10
    dbase = Dispatch('IPhreeqcCOM.Object')

  File ~\anaconda3\Lib\site-packages\win32com\client\__init__.py:118 in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:104 in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:86 in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(

com_error: (-2147023782, 'A dynamic link library (DLL) initialization routine failed.', None, None)

--- End quote ---

The code is the following, and it crashes in the second line (Dispatch)


--- Quote ---from win32com.client import Dispatch
dbase = Dispatch('IPhreeqcCOM.Object')
db_path = '1-database/WATEQ4F.DAT'
dbase.LoadDatabase(db_path)

--- End quote ---


I made a fresh install for everything (Anaconda- Python, and IPHREEQCCOM 3.73 x64 and x32). I also tried updating-reinstalling-uninstalling the win32 python library and tried it with other commands (works ok). And of course repair-reinstall for both x64 and x32 msi files for Iphreeqccom.
Nothing seems to fix the issue and I'm running out of options. The only difference I can tell from my previous computers is that this one has Windows 11 installed. Has anyone experienced this error?

Anyway, is not that terrible, maybe it's time to use PhreeqPy

Cheers!


charlton:
Hi, my best guess is that a dll that the phreeqccom dll requires is missing from windows 11.  I don't currently have a windows 11 machine to test this on.  As soon as I can test it I'll let you know.

Scott

charlton:
I was able to test on a windows 11 virtual machine and I think I found the problem.  When IPhreeqcCOM is installed it checks to make sure the .NET framework is installed.  Windows 11 (and possibly Windows 10) reports that the .NET framework is installed during the IPhreeqcCOM installation but it really isn't and is supposed to display a .NET installation the first time you attempt to use IPhreeqcCOM.  For some reason the .NET installation window is not shown when running in python.

Probably, the easiest solution is to attempt to instantiate a IPhreeqcCOM from within a powershell command prompt:

  type pwsh in the search bar and select the PowerShell 7 app

  type
     
--- Code: ---$com = New-Object -ComObject IPhreeqcCOM.Object
--- End code ---

  in the command prompt and it should display a dialog to install .NET Framework 3.5.

I'm not sure pwsh is installed by default on Windows 11 but I think it is.  Otherwise, you could search the Microsoft website for the .NET Framework 3.5 installer (or possibly use the Windows Features functionality within Windows itself to install it).

You might want to reboot windows before trying this in case the installer window has been hidden.

Let me know if this helps.
Scott


charlton:
I created a gist to install .NET 3.5 on Windows 11:

https://gist.github.com/scharlton2/b8dd1ccd2820c62859c8e7ac5d1ccc2e

Leonardo:

Thanks, Scott.

I ran a preliminary test (just trying the line dbase = Dispatch('IPhreeqcCOM.Object')) and it's working. Thank you so much for your impressively quick reply.

Cheers

Navigation

[0] Message Index

[#] Next page

Go to full version