Failed building wheel for llvmlite
Closed this issue · 4 comments
Hello,
I was trying to use Climate Indices on my meteorological dataset by Win Anaconda and Win Clear Python. I always have some issues.
For example on clear python ( I know about the closed issue and it seems that date format is in correct format in my nc file):
TypeError: expected str, bytes or os.PathLike object, not NoneType
or by testing by yours nclimgrid_lowres_prcp.nc if something is different in my and yours dataset:
process_climate_indices --index spi --periodicity monthly --netcdf_precip "./nclimgrid_lowres_prcp.nc" --var_name_precip prcp --output_file_base "./Agrometeorological indicators/" --scales 6 --calibration_start_year 1895 --calibration_end_year 2017 --multiprocessing all
Output:
File "c:\users\lukat\scoop\apps\python\current\lib\site-packages\climate_indices\indices.py", line 110:
def spi(
<source elided>
# or to (years, 366) for daily
if periodicity is compute.Periodicity.monthly:
^
So I decided to use WSL Python after reading the issues here and since it seems as the most stable system.
sudo pip3 install climate-indices
I have an error with llvmlite:
Failed building wheel for llvmlite
I was trying to find a solution but unsuccessful. There are lots of tutorials however, no one really helps me...
Okay
Seems that Anaconda on Linux will be the most suitable solution. "Failed building wheel for llvmlite" - seems that this is only an issue of clear python and pip installation. The test run goes well with nclimgrid_lowres_prcp.nc
However with my cropped file, the issue is still same:
TypeError: expected str, bytes or os.PathLike object, not NoneType
I will try to find a solution with xarray or NetCDF4.
Okay! I got it!
You need to put in the right order dimensions!
<xarray.Dataset>
Dimensions: (lat: 115, lon: 140, time: 15157)
Coordinates:
* lat (lat) float64 -7.4 -7.5 -7.6 -7.7 ... -18.6 -18.7 -18.8
* lon (lon) float64 21.1 21.2 21.3 21.4 ... 34.8 34.9 35.0
* time (time) datetime64[ns] 1979-01-01 ... 2020-06-30
Data variables:
Precipitation_Flux (time, lat, lon) float32 ...
Attributes:
CDI: Climate Data Interface version 1.9.2 (http://mpimet.mpg.de/...
history: Sat Nov 28 18:08:48 2020: ncks -v Precipitation_Flux -d lon...
Conventions: CF-1.7
CDO: Climate Data Operators version 1.9.2 (http://mpimet.mpg.de/...
NCO: netCDF Operators version 4.7.9 (Homepage = http://nco.sf.ne...
So this should work!
import xarray as xr
data = data.transpose("lat", "lon", "time")
Sorry I couldn't help with this earlier, @Amarounek
What was the cause of the initial TypeError
? I'm curious about that because I thought the dimensions being out of order should cause a separate error. But maybe something else was going on?
No problem!
Well If I run it on Windows Python distribution (all installed by pip, however I am not quite sure how NCO is solved):
process_climate_indices --index spi --periodicity monthly --netcdf_precip monthly_output2.nc --var_name_precip Precipitation_Flux --output_file_base ./ --scales 12 --calibration_start_year 1979 --calibration_end_year 2020 --multiprocessing all
I have this type of error:
Traceback (most recent call last):
File "c:\users\lukat\scoop\apps\python\current\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\lukat\scoop\apps\python\current\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\lukat\scoop\apps\python\current\Scripts\process_climate_indices.exe\__main__.py", line 7, in <module>
File "c:\users\lukat\scoop\apps\python\current\lib\site-packages\climate_indices\__main__.py", line 1684, in main
_compute_write_index(kwrgs)
File "c:\users\lukat\scoop\apps\python\current\lib\site-packages\climate_indices\__main__.py", line 1011, in _compute_write_index
_parallel_process(keyword_arguments["index"],
File "c:\users\lukat\scoop\apps\python\current\lib\site-packages\climate_indices\__main__.py", line 1298, in _parallel_process
pool.map(_apply_along_axis, chunk_params)
File "c:\users\lukat\scoop\apps\python\current\lib\multiprocessing\pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "c:\users\lukat\scoop\apps\python\current\lib\multiprocessing\pool.py", line 771, in get
raise self._value
numba.core.errors.UnsupportedError: Failed in object mode pipeline (step: analyzing bytecode)
Use of unsupported opcode (IS_OP) found
File "c:\users\lukat\scoop\apps\python\current\lib\site-packages\climate_indices\indices.py", line 110:
def spi(
<source elided>
# or to (years, 366) for daily
if periodicity is compute.Periodicity.monthly:
So I installed the Anaconda on WSL and I was able to get over the Failed building wheel for llvmlite
during the Python distribution installation on WSL.
Then my script was easy:
import netCDF4
from netCDF4 import Dataset
import xarray as xr
data = xr.open_dataset('C3S_concat_cropped.nc')
data = data.transpose("lat", "lon", "time")
monthly_dataset = data['Precipitation_Flux'].resample(time ='m', skipna=False).sum()
monthly_dataset.attrs['units'] = 'mm'
new_filename_1 = './monthly_output2.nc'
print ('saving to ', new_filename_1)
monthly_dataset.to_netcdf(path=new_filename_1)
Following Climate Indices run was successful!
I cannot tell you about the Climate Indices installation in Anaconda distribution on Windows since I was going after the easiest way.