Package pyhwm14 errors out on import statement

130 Views Asked by At

I need the Horizontal wind model for my bachelor thesis, for which i need the aerodynamic velocity of a spacecraft. I checked for multiple wind models which provide wind velocity in the upper atmosphere, and the best one was indeed hwm, which source is written in Fortran90.

Luckily, there is a python wrapper package called pyhwm14. The installation using pip goes fine. But when i come to use the package as follows:

from pyhwm2014.pyhwm14 import HWM14, HWM14Plot

the following error pops.

 File "C:\-\lib\site-packages\pyhwm2014\__init__.py", line 7, in <module>
    from . import hwm14
ImportError: DLL load failed while importing hwm14: The module could not be found. 

To resolve the error i tried to look in the package folder directory and have the following picture for the files:

  1. .libs

  2. _pycache_

  3. _init_.py

  4. hwm14.cp310-win_amd64.pyd

I assumed the file hwm14 that needs to be imported in the _init_.py can only be the hwm14.cp310-win_amd64.pyd file, which exists in the directory, but why is Python not finding it and not running?

Resolve the import error or find other package with no issues like this.

Ofcourse if someone has experience with wrappers and can teach me how to use the source f90 code in python, this also would be greate.

Thank you everyone

1

There are 1 best solutions below

1
lazySeal On

Try this:

  1. Install mingw64 (x86_64-8.1.0-release-posix-seh-rt_v6-rev0 worked for me)
  2. Add bin folder of mingw64 to the PATH
  3. Go to the project root folder
  4. Run installation from the source code from https://github.com/rilma/pyHWM14
    git clone https://github.com/rilma/pyHWM14.git
    cd pyHWM14
    pip -q install coveralls 
    pip install numpy 
    pip install -e .
  1. Find .dll file in \pyHWM14\pyhwm2014.libs, copy it to the upper level

  2. Copy the contents of the \pyHWM14\data (two .dat and one .bin files should be there) to the C:\ (or whatever your root directory is)

  3. coverage run tests/test.py -v