Skip to content

Installing Python wrapper on Windows, cannot find .dll files #73

@atmosalex

Description

@atmosalex

Hi, I successfully built IRBEM following the instructions to make libirbem.dll. Then I installed the Python wrapper by running pip install -e . from the IRBEM\python directory

First minor issue: some of the .dll dependencies are not in the correct place: running ldd .\libirbem.dll shows incorrect paths. I managed to fix this by creating symbolic links. This might be an issue with my environment rather than IRBEM.

However, the main issue is, the code:

import IRBEM as ib
a = ib.Coords()

results in this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\IRBEM\python\IRBEM\IRBEM.py", line 1005, in __init__
    self.path, self._irbem_obj = _load_shared_object(self.irbem_obj_path)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\IRBEM\python\IRBEM\IRBEM.py", line 1170, in _load_shared_object
    _irbem_obj = ctypes.WinDLL(str(path))
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alex\.conda\envs\atm\Lib\ctypes\__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 127] The specified procedure could not be found

This is not an issue with IRBEM itself, it is caused because ctypes cannot find the dll's. I believe it might be because since Python 3.8, the system's standard PATH variable is no longer used to search for dll dependencies.

I managed to fix this issue by adding the following lines of code to my script before importing IRBEM:

os.add_dll_directory("/WINDOWS/SYSTEM32")
os.add_dll_directory("/Users/Alex/.conda/envs/atm/Library/mingw-w64/bin")
os.add_dll_directory("/ucrt64/bin")
os.add_dll_directory("/WINDOWS/System32")

Obviously these relate to my environment and this method is not a real fix. However I thought explaining my issues here might help to make IRBEM easier to install in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions