netcdf4-python icon indicating copy to clipboard operation
netcdf4-python copied to clipboard

Compiling from source picks up a nonexistent numpy and fails

Open AgilentGCMS opened this issue 3 months ago • 3 comments

I am trying to build netCDF4 1.6.5 from source with pip install .. It is failing with a numpy error, namely

Processing /home/sbasu1/Downloads/sources/netCDF4-1.6.5
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [59 lines of output]
      Package hdf5 was not found in the pkg-config search path.
      Perhaps you should add the directory containing `hdf5.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'hdf5', required by 'virtual:world', not found
      reading from setup.cfg...
      using /home/sbasu1/packages/bin/nc-config...
      checking /home/sbasu1/packages/include ...
      HDF5 library version: 1.14.0 headers found in /home/sbasu1/packages/include
      Traceback (most recent call last):
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/__init__.py", line 23, in <module>
          from . import multiarray
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in <module>
          from . import overrides
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/overrides.py", line 6, in <module>
          from numpy.core._multiarray_umath import (
      ImportError: /tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so: failed to map segment from shared object

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/sbasu1/packages/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/sbasu1/packages/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/sbasu1/packages/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 543, in <module>
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/__init__.py", line 140, in <module>
          from . import core
        File "/tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/__init__.py", line 49, in <module>
          raise ImportError(msg)
      ImportError:

      IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

      Importing the numpy C-extensions failed. This error can happen for
      many reasons, often due to issues with your setup or how NumPy was
      installed.

      We have compiled some common reasons and troubleshooting tips at:

          https://numpy.org/devdocs/user/troubleshooting-importerror.html

      Please note and check the following:

        * The Python version is: Python3.11 from "/home/sbasu1/packages/bin/python3"
        * The NumPy version is: "1.23.2"

      and make sure that they are the versions you expect.
      Please carefully study the documentation linked above for further help.

      Original error was: /tmp/pip-build-env-36b_0j_r/overlay/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so: failed to map segment from shared object

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

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

What is baffling to me is the numpy version 1.23.2. That is not the numpy version I have installed.

$ python -c 'import numpy; print(numpy.__version__)'
1.26.4

I can in fact import numpy and work with numpy functions. I have scoured my system and that's the only version of numpy I have. So where is this 1.23.2 coming from, that is not letting me install netCDF4?

AgilentGCMS avatar Apr 04 '24 18:04 AgilentGCMS