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
392 stars 149 forks source link

ImportError -> from wrf import getvar #221

Open Yeshus-U opened 5 months ago

Yeshus-U commented 5 months ago

Hi everyone,

I'm encountering issues while installing WRF Python. Specifically, I'm unable to import the 'getvar' library from WRF. Could anyone please assist me? Machine -> Apple M2 which gcc-> /usr/bin/gcc whicg gfortran -> /opt/homebrew/bin/gfortran

The error message I'm receiving is:

ImportError Traceback (most recent call last) /var/folders/ld/xm4cx30j32gbl86n_0gb13xh0000gn/T/xpython_3902/2103250201.py in 2 import numpy as np 3 import xarray as xr ----> 4 from wrf import getvar 5 get_ipython().run_line_magic('matplotlib', 'widget') 6 import matplotlib.pyplot as plt

getvar error
Yeshus-U commented 5 months ago

I'm new to this environment. When attempting to install WRF-Python using the following command:


conda install -c conda-forge wrf-python

The following packages will be UPDATED:

  ca-certificates                       2023.5.7-h8857fd0_0 --> 2023.11.17-h8857fd0_0 
  certifi                             2023.5.7-pyhd8ed1ab_0 --> 2023.11.17-pyhd8ed1ab_0 
  matplotlib         pkgs/main::matplotlib-3.5.2-py39hecd8~ --> conda-forge::matplotlib-3.5.3-py39h6e9494a_2 
  openssl                                 1.1.1t-hfd90126_0 --> 1.1.1w-h8a1eda9_0 

Proceed ([y]/n)? y

However, during the process, I encountered a 'RemoveError' stating:

RemoveError: 'requests' is a dependency of conda and cannot be removed from conda's operating environment.
![Uploading error_2.png…]()
FelixLangot commented 5 months ago

Similar issue here, I did not have wrf-python installed on my machine (M2 Pro). I tried all the conda installation syntaxes provided here: https://anaconda.org/conda-forge/wrf-python. I always get the PackageNotFoundError:

conda install -c conda-forge wrf-python Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • wrf-python

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

In last resort, I tried with pip, but still got an error (I am only including part of the message here):

     57 |     REAL(KIND=8), DIMENSION(150,150) :: PSADITMK
        |                                                1
  Warning: Array 'psaditmk' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider increasing the '-fmax-stack-var-size=' limit (or use '-frecursive', which implies unlimited '-fmax-stack-var-size') - or change the code to use an ALLOCATABLE array. If the variable is never accessed concurrently, this warning can be ignored, and the variable could also be declared with the SAVE attribute. [-Wsurprising]
  INFO: gfortran:f90: fortran/wrf_pw.f90
  INFO: gfortran:f90: fortran/wrf_vinterp.f90
  INFO: gfortran:f90: fortran/wrf_wind.f90
  INFO: gfortran:f90: build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers2.f90
  INFO: gfortran:f77: build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers.f
  INFO: /usr/local/bin/gfortran -Wall -g -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortranmodule.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/build/src.macosx-11.0-arm64-3.11/wrf/fortranobject.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_constants.o build/temp.macosx-11.0-arm64-cpython-311/fortran/omp.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_testfunc.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user.o build/temp.macosx-11.0-arm64-cpython-311/fortran/rip_cape.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_cloud_fracf.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_fctt.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user_dbz.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_relhl.o build/temp.macosx-11.0-arm64-cpython-311/fortran/calc_uh.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user_latlon_routines.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_pvo.o build/temp.macosx-11.0-arm64-cpython-311/fortran/eqthecalc.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_rip_phys_routines.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_pw.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_vinterp.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_wind.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers2.o -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12 -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12/../../.. -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12/../../.. -lgfortran -o build/lib.macosx-11.0-arm64-cpython-311/wrf/_wrffortran.cpython-311-darwin.so
  ld: library not found for -lSystem
  collect2: error: ld returned 1 exit status
  error: Command "/usr/local/bin/gfortran -Wall -g -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortranmodule.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/build/src.macosx-11.0-arm64-3.11/wrf/fortranobject.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_constants.o build/temp.macosx-11.0-arm64-cpython-311/fortran/omp.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_testfunc.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user.o build/temp.macosx-11.0-arm64-cpython-311/fortran/rip_cape.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_cloud_fracf.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_fctt.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user_dbz.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_relhl.o build/temp.macosx-11.0-arm64-cpython-311/fortran/calc_uh.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_user_latlon_routines.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_pvo.o build/temp.macosx-11.0-arm64-cpython-311/fortran/eqthecalc.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_rip_phys_routines.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_pw.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_vinterp.o build/temp.macosx-11.0-arm64-cpython-311/fortran/wrf_wind.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers.o build/temp.macosx-11.0-arm64-cpython-311/build/src.macosx-11.0-arm64-3.11/wrf/_wrffortran-f2pywrappers2.o -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12 -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12/../../.. -L/usr/local/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/x86_64-apple-darwin21/12/../../.. -lgfortran -o build/lib.macosx-11.0-arm64-cpython-311/wrf/_wrffortran.cpython-311-darwin.so" failed with exit status 1
  INFO:
  ########### EXT COMPILER OPTIMIZATION ###########
  INFO: Platform      :
    Architecture: aarch64
    Compiler    : clang

  CPU baseline  :
    Requested   : 'min'
    Enabled     : NEON NEON_FP16 NEON_VFPV4 ASIMD
    Flags       : none
    Extra checks: none

  CPU dispatch  :
    Requested   : 'max -xop -fma4'
    Enabled     : ASIMDHP ASIMDDP ASIMDFHM
    Generated   : none
  INFO: CCompilerOpt.cache_flush[857] : write cache to path -> /private/var/folders/v0/v8wcct2x3290xygcx8txfn1c0000gn/T/pip-install-h3pk___y/wrf-python_d4a9dafc8b2941dd8481fe27e40e495f/build/temp.macosx-11.0-arm64-cpython-311/ccompiler_opt_cache_ext.py
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> wrf-python

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

Thanks for the help!

kafitzgerald commented 4 months ago

Yeah, WRF-Python is not yet available on conda-forge for M1/M2 machines, but has gotten substantially easier to build (see my comment on #199). Hopefully, we'll get a release over there soon so it's possible to just install using conda.