phreeqpython
phreeqpython copied to clipboard
v1.5.0 works but 1.5.1/2 do not with `libIPhreeqc.so.3.6.3`
i cloned & compiled https://github.com/Vitens/VIPhreeqc for my aarch64 then replaced default libraries that came with pip
pip install phreeqpython==1.5.0
cd xxx/python3.10/site-packages/phreeqpython/lib
rm *
ln -s /usr/local/lib/libIPhreeqc.so.3.6.3 viphreeqc.so
everything works
In [1]: from phreeqpython import PhreeqPython
...: pp = PhreeqPython()
...: # add a solution consisting of 1 mmol CaCl2 and 2 mmol NaHCO3
...: solution = pp.add_solution_simple({'CaCl2':1.0,'NaHCO3':2.0})
...: print(solution.pH) # 8.12
...: print(solution.sc) # 427.32
...: print(solution.si('Calcite')) # 0.38
...: print(solution.species['HCO3-']) # 0.0019
...: print(solution.elements['Cl']) # 0.002 mol
8.122771293869048
427.00938278999627
0.3840663711528194
0.001921455714893849
0.0020000000000000005
but when I upgrade pip install phreeqpython==1.5.2 the above procedure is repeated but now it gives me
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 2
1 from phreeqpython import PhreeqPython
----> 2 pp = PhreeqPython()
3 # add a solution consisting of 1 mmol CaCl2 and 2 mmol NaHCO3
4 solution = pp.add_solution_simple({'CaCl2':1.0,'NaHCO3':2.0})
File ~/.local/lib/python3.10/site-packages/phreeqpython/phreeqpython.py:19, in PhreeqPython.__init__(self, database, database_directory, from_file, debug)
16 def __init__(self, database=None, database_directory = None, from_file=None,
17 debug=False):
18 # Create VIPhreeqc Instance
---> 19 self.ip = VIPhreeqc()
20 self.ip.debug = debug
21 self.chain = False
File ~/.local/lib/python3.10/site-packages/phreeqpython/viphreeqc.py:106, in VIPhreeqc.__init__(self, dll_path)
53 self.dll = phreeqc
54 c_int = ctypes.c_int
55 method_mapping = [('_accumulate_line', phreeqc.AccumulateLine,
56 [c_int, ctypes.c_char_p], c_int),
57 ('_add_error', phreeqc.AddError,
58 [c_int, ctypes.c_char_p], c_int),
59 ('_add_error', phreeqc.AddWarning,
60 [c_int, ctypes.c_char_p], c_int),
61 ('_clear_accumlated_lines',
62 phreeqc.ClearAccumulatedLines, [c_int], c_int),
63 ('_create_iphreeqc', phreeqc.CreateIPhreeqc,
64 [ctypes.c_void_p], c_int),
65 ('_destroy_iphreeqc', phreeqc.DestroyIPhreeqc,
66 [c_int], c_int),
67 ('_get_component', phreeqc.GetComponent,
68 [c_int, c_int], ctypes.c_char_p),
69 ('_get_component_count', phreeqc.GetComponentCount,
70 [c_int], c_int),
71 ('_get_dump_string', phreeqc.GetDumpString,
72 [c_int], ctypes.c_char_p),
73 ('_set_dump_string_on', phreeqc.SetDumpStringOn,
74 [c_int], c_int),
75 ('_get_error_string', phreeqc.GetErrorString,
76 [c_int], ctypes.c_char_p),
77 ('_get_selected_output_column_count',
78 phreeqc.GetSelectedOutputColumnCount, [c_int],
79 c_int),
80 ('_get_selected_output_row_count',
81 phreeqc.GetSelectedOutputRowCount, [c_int], c_int),
82 ('_get_value', phreeqc.GetSelectedOutputValue,
83 [c_int, c_int, c_int, ctypes.POINTER(VAR)], c_int),
84 ('_load_database', phreeqc.LoadDatabase,
85 [c_int, ctypes.c_char_p], c_int),
86 ('_load_database_string', phreeqc.LoadDatabaseString,
87 [c_int, ctypes.c_char_p], c_int),
88 ('_run_string', phreeqc.RunString,
89 [c_int, ctypes.c_char_p], c_int),
90 ('_set_selected_output_file_on',
91 phreeqc.SetSelectedOutputFileOn, [c_int, c_int],
92 c_int),
93 # VIPHREEQC Additions:
94 # gas
95 ('_get_gas_volume', phreeqc.GetGasVolume,
96 [c_int, c_int], ctypes.c_double),
97 ('_get_gas_pressure', phreeqc.GetGasPressure,
98 [c_int, c_int], ctypes.c_double),
99 ('_get_gas_total_moles', phreeqc.GetGasTotalMoles,
100 [c_int, c_int], ctypes.c_double),
101 ('_get_gas_components', phreeqc.GetGasComponents,
102 [c_int, c_int], ctypes.c_char_p),
103 ('_get_gas_component_moles', phreeqc.GetGasComponentMoles,
104 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
105 # equilbrium phase
--> 106 ('_get_equilibrium_phase_components', phreeqc.GetEquilibriumPhaseComponents,
107 [c_int, c_int], ctypes.c_char_p),
108 ('_get_equilibrium_phase_component_moles', phreeqc.GetEquilibriumPhaseComponentMoles,
109 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
110 # solution
111 ('_get_ph', phreeqc.GetPH,
112 [c_int, c_int], ctypes.c_double),
113 ('_get_pe', phreeqc.GetPe,
114 [c_int, c_int], ctypes.c_double),
115 ('_get_sc', phreeqc.GetSC,
116 [c_int, c_int], ctypes.c_double),
117 ('_get_mu', phreeqc.GetMu,
118 [c_int, c_int], ctypes.c_double),
119 ('_get_temperature', phreeqc.GetTemperature,
120 [c_int, c_int], ctypes.c_double),
121 ('_get_mass', phreeqc.GetMass,
122 [c_int, c_int], ctypes.c_double),
123 ('_get_total', phreeqc.GetTotal,
124 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
125 ('_get_total_element', phreeqc.GetTotalElement,
126 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
127 ('_get_total_ion', phreeqc.GetTotalIon,
128 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
129 ('_get_moles', phreeqc.GetMoles,
130 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
131 ('_get_activity', phreeqc.GetActivity,
132 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
133 ('_get_molality', phreeqc.GetMolality,
134 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
135 ('_get_species', phreeqc.GetSpecies,
136 [c_int, c_int], ctypes.c_char_p),
137 ('_get_species_masters', phreeqc.GetSpeciesMasters,
138 [c_int, c_int], ctypes.c_char_p),
139 ('_get_phases', phreeqc.GetPhases,
140 [c_int, c_int], ctypes.c_char_p),
141 ('_get_elements', phreeqc.GetElements,
142 [c_int, c_int], ctypes.c_char_p),
143 ('_get_si', phreeqc.GetSI,
144 [c_int, c_int, ctypes.c_char_p], ctypes.c_double),
145 ('_get_solution_list', phreeqc.GetSolutionList,
146 [c_int], ctypes.c_char_p)
147 ]
148 for name, com_obj, argtypes, restype in method_mapping:
149 com_obj.argtypes = argtypes
File /usr/lib/python3.10/ctypes/__init__.py:387, in CDLL.__getattr__(self, name)
385 if name.startswith('__') and name.endswith('__'):
386 raise AttributeError(name)
--> 387 func = self.__getitem__(name)
388 setattr(self, name, func)
389 return func
File /usr/lib/python3.10/ctypes/__init__.py:392, in CDLL.__getitem__(self, name_or_ordinal)
391 def __getitem__(self, name_or_ordinal):
--> 392 func = self._FuncPtr((name_or_ordinal, self))
393 if not isinstance(name_or_ordinal, int):
394 func.__name__ = name_or_ordinal
AttributeError: /home/ukhan/.local/lib/python3.10/site-packages/phreeqpython/./lib/viphreeqc.so: undefined symbol: GetEquilibriumPhaseComponents