Vitens / phreeqpython

Object-oriented python wrapper for the VIPhreeqc module
Apache License 2.0
68 stars 19 forks source link

Error 126 when running module phreeqpython #3

Closed Homoni closed 5 years ago

Homoni commented 5 years ago

I've tried this version of phreeqpython and the version on pip. Both give this Error 126. Do you know how to fix this error? It can run on command line and ipython in command line. However, it cannot run in an IDE like Spyder or Canopy.

import phreeqpython as phre

pp = phre.PhreeqPython() Traceback (most recent call last):

File "", line 1, in pp = phre.PhreeqPython()

File "C:\Users\Lohen\Miniconda2\lib\site-packages\phreeqpython\phreeqpython.py", line 15, in init self.ip = VIPhreeqc()

File "C:\Users\Lohen\Miniconda2\lib\site-packages\phreeqpython\viphreeqc.py", line 51, in init phreeqc = ctypes.cdll.LoadLibrary(dll_path)

File "C:\Users\Lohen\Miniconda2\lib\ctypes__init__.py", line 444, in LoadLibrary return self._dlltype(name)

File "C:\Users\Lohen\Miniconda2\lib\ctypes__init.py", line 366, in init__ self._handle = _dlopen(self._name, mode)

WindowsError: [Error 126] The specified module could not be found

AbelHeinsbroek commented 5 years ago

First thing, can you confirm that you're using a 64-bit version of Miniconda?

There is a problem with installing PhreeqPython on miniconda that I havent got around to fixing. Can you confirm there is a folder 'lib' inside: C:\Users\Lohen\Miniconda2\lib\site-packages\phreeqpython\

If not, create the lib folder and download and unzip this file there.

If PhreeqPython then starts complaining about missing database files, create a folder named 'database' in the same directory and download the files from this folder

Homoni commented 5 years ago

I am running the miniconda 64 version. It was missing the lib folder and dll file. It is now running. Thanks

martinwk commented 4 years ago

Hi, this issue still remains. Is there any chance this is going to be solved? Is there something we can do to help maybe?

AbelHeinsbroek commented 4 years ago

Strange, this only seems to be an issue when using pip install, when you download the files and use python3 setup.py install the download of database and binaries works fine.

I added the binaries and database to the pip package, can you confirm that it installs ok now?

martinwk commented 4 years ago

Unfortunately it is still not installing correctly. Looking at the install logs I see

  running install
  Fetching latest VIPhreeqc build from ci...
  Downloading to: C:\Users\korevma\AppData\Local\Temp\pip-req-build-ulmt7rnp\phreeqpython\lib\viphreeqc.zip
  Unpacking library to: C:\Users\korevma\AppData\Local\Temp\pip-req-build-ulmt7rnp\phreeqpython\lib
  Done!

It seems the library is unpacked to the wrong path. The path of the file is used to determine that path but it seems pip is using a tmp folder where files are saved as intermedeate step. E.g. it is also doing:

 copying phreeqpython\gas.py -> build\lib\phreeqpython
  copying phreeqpython\phreeqpython.py -> build\lib\phreeqpython
  copying phreeqpython\solution.py -> build\lib\phreeqpython
  copying phreeqpython\test.py -> build\lib\phreeqpython
  copying phreeqpython\utility.py -> build\lib\phreeqpython
  copying phreeqpython\viphreeqc.py -> build\lib\phreeqpython

I think the solution lies somewhere in this.

martinwk commented 4 years ago

In this SO answer it is suggested to add it as dependency in the setup.py and load it in the __init__ of the package.