NCAR / wrf-python

A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
https://wrf-python.readthedocs.io
Apache License 2.0
409 stars 154 forks source link

_wrffortran cannot be found after installing from source #208

Open am-thyst opened 1 year ago

am-thyst commented 1 year ago

pip install . runs successfully, but when importing wrf in python I get the following error:

Traceback (most recent call last):
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\__init__.py", line 6, in <module>
    from . import api
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\api.py", line 1, in <module>
    from .config import (xarray_enabled, disable_xarray, enable_xarray,
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\config.py", line 6, in <module>
    from ._wrffortran import (fomp_enabled, fomp_set_num_threads,
ImportError: DLL load failed while importing _wrffortran: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\__init__.py", line 18, in <module>
    from . import api
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\api.py", line 1, in <module>
    from .config import (xarray_enabled, disable_xarray, enable_xarray,
  File "C:\Users\User\anaconda3\envs\wrfenv_rcapetest\Lib\site-packages\wrf-python\src\wrf\config.py", line 6, in <module>
    from ._wrffortran import (fomp_enabled, fomp_set_num_threads,
ImportError: DLL load failed while importing _wrffortran: The specified module could not be found.

I'm trying to install from source so I can have more control over the calculations in the fortran scripts. I'm happy to use conda install if there's some way to manually change the fortran calculations, but I can't see that functionality.

Versions:

jnava1612 commented 12 months ago

Got the same error while trying to work with Python 3.11.1, however it's the first time i got the error, since I was able to use wrf-python without any errors before. Were you able to solve it?

DWesl commented 4 months ago

My guess would be either PATH issues (you linked against some libraries python can't find: try copying them to the same directory as _wrffortran. The Fortran runtime library is the most obvious candidate) or permission issues (try the Windows version of chmod u+x _wrffortran*.dll). You can get more detail with python -vvvdc 'import wrf', but I'm guessing you've checked the big thing it would tell you (does site-packages/wrf/_wrffortran.*py311*.dll (or whatever the name is) exist, and do the tags in the name match the python implementation?)

As an alternative, are the variants on the calculations in Fortran something you think others would be interested in? If so, submitting those as a PR might be able to side-step the problems with building from source.