Failed building wheel for cftime while trying to pip install netCDF4 on Ubuntu Linux

247 Views Asked by At

I am trying to pip install the netCDF4 packages on Ubuntu. This is the output:

Collecting netCDF4
  Obtaining dependency information for netCDF4 from https://files.pythonhosted.org/packages/5b/a8/065c37eb1815239a1bd2bb88b5e65ff77f8b1bb676330c803314c5f099ec/netCDF4-1.6.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata
  Using cached netCDF4-1.6.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (1.6 kB)
Collecting cftime (from netCDF4)
  Using cached cftime-1.6.2.tar.gz (52 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting certifi (from netCDF4)
  Obtaining dependency information for certifi from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
  Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Requirement already satisfied: numpy in ./virtualenv/lib/python3.10/site-packages (from netCDF4) (1.25.2)
Using cached netCDF4-1.6.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.0 MB)
Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
Building wheels for collected packages: cftime
  Building wheel for cftime (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for cftime (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-310
      creating build/lib.linux-aarch64-cpython-310/cftime
      copying src/cftime/__init__.py -> build/lib.linux-aarch64-cpython-310/cftime
      copying src/cftime/_strptime.py -> build/lib.linux-aarch64-cpython-310/cftime
      running build_ext
      building 'cftime._cftime' extension
      creating build/temp.linux-aarch64-cpython-310
      creating build/temp.linux-aarch64-cpython-310/tmp
      creating build/temp.linux-aarch64-cpython-310/tmp/pip-install-9_n4g68u
      creating build/temp.linux-aarch64-cpython-310/tmp/pip-install-9_n4g68u/cftime_7990bd36e03a4c39977057d006aef814
      creating build/temp.linux-aarch64-cpython-310/tmp/pip-install-9_n4g68u/cftime_7990bd36e03a4c39977057d006aef814/src
      creating build/temp.linux-aarch64-cpython-310/tmp/pip-install-9_n4g68u/cftime_7990bd36e03a4c39977057d006aef814/src/cftime
      aarch64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/tmp/pip-build-env-756vby7x/overlay/lib/python3.10/site-packages/numpy/core/include -I/home/dmusic/virtualenv/include -I/usr/include/python3.10 -c /tmp/pip-install-9_n4g68u/cftime_7990bd36e03a4c39977057d006aef814/src/cftime/_cftime.c -o build/temp.linux-aarch64-cpython-310/tmp/pip-install-9_n4g68u/cftime_7990bd36e03a4c39977057d006aef814/src/cftime/_cftime.o
      error: command 'aarch64-linux-gnu-gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cftime
Failed to build cftime
ERROR: Could not build wheels for cftime, which is required to install pyproject.toml-based projects

The main errors I see here are: 'Failed to build cftime' and 'error: command 'aarch64-linux-gnu-gcc' failed: No such file or directory'.

I already tried updating pip, installing and updating wheel, disabling the cached copy, and multiple other solutions when looking online. Nothing works. I would much appreciate the help. Thank you.

1

There are 1 best solutions below

0
Ken Williams On

If you install the python3-dev package, that will install the gcc package as a dependency (and a bunch of other stuff you're probably going to need in order to install NetCDF4), including the aarch64-linux-gnu-gcc executable.

So try this:

sudo apt-get install python3-dev