Hi, newbie here. Having some trouble with installation.


#1

python3.11 on win10

A project I was asked to work on involves netCDF4.
I attempted to install the associated python library netCDF4 and obtained errors.
I discovered through the internet that I needed the library downloads for HDF and netCDF.
Downloaded, installed, yadah yadah. I even manually set my environment variables:

$env:NETCDF4_DIR='C:\Program Files\netCDF 4.9.0\lib'
$env:HDF5_DIR='C:\Program Files\HDF_Group\HDF5\1.12.2'
$env:LIB='C:\Program Files\HDF_Group\HDF5\1.12.2\lib'

When I run python -m pip -v install h5py --upgrade --no-dependencies --force,
I get the error:

 error: subprocess-exited-with-error

  × Building wheel for h5py (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\Python\python.exe' 'C:\Python\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\ADMINI~1\AppData\Local\Temp\tmpi6odl3j0'
  cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-mmc3pikl\h5py_1e32026ad6ed45b8b809e64a985d4ec7
  Building wheel for h5py (pyproject.toml) ... error
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects

When I run the command python -m pip -v install netCDF4 --upgrade --no-dependencies --force,
I get the error

error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\Python\python.exe' -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize

  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)

  __file__ = %r
  sys.argv[0] = __file__

  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"

  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-ha0g1idw\\netcdf4_bec4875121c54f17950324b8c0e62eec\\setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base 'C:\Users\Administrator\AppData\Local\Temp\pip-pip-egg-info-08ezy7ri'
  cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-ha0g1idw\netcdf4_bec4875121c54f17950324b8c0e62eec\
  Preparing metadata (setup.py) ... error
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.

Not sure what is wrong, please advise <3


#2

Hi @geraldsmeyers,

h5py does not currently provide Python 3.11 wheels so that’s why you got the error trying to install it. Not sure about the netcdf4 Python package error.

Suggestions how to proceed:

  • Consider using Python 3.10. Perhaps not all packages support Python 3.11 given it was released just last week.
  • Use conda package manager instead of pip. conda will save you from building both HDF5 and netCDF libraries in order to install either h5py or netcdf4 packages.
  • If you insist on Python 3.11, you will have to build h5py from source. I assume something similar for netcdf4.

-Aleksandar