fitsio icon indicating copy to clipboard operation
fitsio copied to clipboard

Cannot install fitsio with pip on MacOS Monterrey

Open sharkree opened this issue 1 year ago • 5 comments

Hi, I'm trying to install the most recent version of fitsio using pip, but I'm getting errors related to compiling C fitsio code. Could I get some insights into how to resolve this?

Here are some specifications of my machine:

  • MacOS Monterey 12.7.6
  • Apple M1 Max
  • XCode 14.2
  • Python 3.10.14

Here is the error message I'm getting:

Collecting fitsio (from -r requirements.txt (line 65))
  Using cached fitsio-1.2.4.tar.gz (4.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: async-timeout<5.0,>=4.0 in /Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages (from aiohttp==3.9.0->-r requirements.txt (line 2)) (4.0.3)
Requirement already satisfied: lxml>=4.6.0 in /Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages (from zeep==4.2.1->-r requirements.txt (line 62)) (5.3.0)
Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in /Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages (from numba->-r requirements.txt (line 64)) (0.43.0)
Building wheels for collected packages: fitsio
  Building wheel for fitsio (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for fitsio (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [169 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.macosx-12.2-arm64-cpython-310/fitsio
      copying fitsio/header.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      copying fitsio/util.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      copying fitsio/fits_exceptions.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      copying fitsio/fitslib.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      copying fitsio/__init__.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      creating build/lib.macosx-12.2-arm64-cpython-310/fitsio/hdu
      copying fitsio/hdu/__init__.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/hdu
      copying fitsio/hdu/table.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/hdu
      copying fitsio/hdu/image.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/hdu
      copying fitsio/hdu/base.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/hdu
      creating build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_warnings.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_image_compression.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_table.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_empty_slice.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/checks.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_image.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/__init__.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_lib.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_header.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/makedata.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      copying fitsio/tests/test_header_junk.py -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/tests
      running egg_info
      writing fitsio.egg-info/PKG-INFO
      writing dependency_links to fitsio.egg-info/dependency_links.txt
      writing requirements to fitsio.egg-info/requires.txt
      writing top-level names to fitsio.egg-info/top_level.txt
      reading manifest file 'fitsio.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE.txt'
      writing manifest file 'fitsio.egg-info/SOURCES.txt'
      /private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/command/build_py.py:218: _Warning: Package 'fitsio.test_images' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'fitsio.test_images' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'fitsio.test_images' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'fitsio.test_images' to be distributed and are
              already explicitly excluding 'fitsio.test_images' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      copying fitsio/fitsio_pywrap.c -> build/lib.macosx-12.2-arm64-cpython-310/fitsio
      creating build/lib.macosx-12.2-arm64-cpython-310/fitsio/test_images
      copying fitsio/test_images/test_gzip_compressed_image.fits.fz -> build/lib.macosx-12.2-arm64-cpython-310/fitsio/test_images
      running build_ext
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/configure
      Hunk #3 succeeded at 3787 (offset 1162 lines).
      Hunk #4 succeeded at 3816 with fuzz 1 (offset 1162 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/configure
      Hunk #3 succeeded at 3787 (offset 1162 lines).
      Hunk #4 succeeded at 3816 with fuzz 1 (offset 1162 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitsio.h
      Hunk #1 succeeded at 809 (offset -1 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitsio.h
      Hunk #1 succeeded at 809 (offset -1 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitsio2.h
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitsio2.h
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/putcols.c
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/putcols.c
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitscore.c
      Hunk #1 succeeded at 197 (offset 3 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/fitscore.c
      Hunk #1 succeeded at 197 (offset 3 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/[configure.in](http://configure.in/)
      Hunk #1 succeeded at 129 (offset 76 lines).
      Hunk #2 succeeded at 153 (offset 76 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/[configure.in](http://configure.in/)
      Hunk #1 succeeded at 129 (offset 76 lines).
      Hunk #2 succeeded at 153 (offset 76 lines).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/Makefile.in
      Hunk #1 succeeded at 70 (offset 1 line).
      patching file build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617/Makefile.in
      Hunk #1 succeeded at 70 (offset 1 line).
      checking build system type... aarch64-apple-darwin21.6.0
      checking host system type... aarch64-apple-darwin21.6.0
      checking target system type... aarch64-apple-darwin21.6.0
      checking for clang... clang
      Gabba Hey!: EXT=darwin and CC=clang
      checking whether the C compiler works... no
      configure: error: in `/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-install-un00d5qq/fitsio_d78e5d1f2dc04db79bd6808ac06d91d4/build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617':
      configure: error: C compiler cannot create executables
      See `config.log' for more details
      Traceback (most recent call last):
        File "/Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/[user]/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 421, in build_wheel
          return self._build_with_temp_dir(
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 403, in _build_with_temp_dir
          self.run_setup()
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 503, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 319, in <module>
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 183, in setup
          return run_commands(dist)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
          dist.run_commands()
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py", line 398, in run
          self.run_command("build")
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "<string>", line 106, in run
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 98, in run
          _build_ext.run(self)
        File "/private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-build-env-dmog1cg2/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 359, in run
          self.build_extensions()
        File "<string>", line 130, in build_extensions
        File "<string>", line 272, in configure_cfitsio
      ValueError: could not configure cfitsio 4.4.1-20240617
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fitsio
Failed to build fitsio
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (fitsio)

Many thanks in advance for your help!

sharkree avatar Nov 06 '24 01:11 sharkree

You need to inspect the config.log and figure out why the compiler won't build C code.

beckermr avatar Nov 06 '24 01:11 beckermr

It says checking whether the C compiler works... no

Does your environment not have a C compiler available?

esheldon avatar Nov 06 '24 01:11 esheldon

It should have a C compiler available. I'm able to use clang on MacOS to compile other C programs.

sharkree avatar Nov 06 '24 03:11 sharkree

Yeah you need to look at the config.log file to see what the compiler error is.

beckermr avatar Nov 06 '24 03:11 beckermr

Do you have any workarounds to access the config.log file? Stackoverflow tells me that the config.log file should be in the folder where it errored in, but when I tried to cd into the the /private/var/folders/yv/whcx9ccx5cx0ln0dbq_9lz6m000mqx/T/pip-install-un00d5qq/fitsio_d78e5d1f2dc04db79bd6808ac06d91d4/build/temp.macosx-12.2-arm64-cpython-310/cfitsio-4.4.1-20240617 folder, it said the folder didn't exist.

danielkou5855 avatar Nov 08 '24 02:11 danielkou5855