pip install --upgrade fitsio : ValueError: could not configure cfitsio 3470

pip install --upgrade fitsio : ValueError: could not configure cfitsio 3470

我正在尝试更新 cfitsio python 库,但收到一个我无法理解的错误(除了 Python2.7 警告):

~$ sudo pip install --upgrade fitsio
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/home/username/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting fitsio
  Downloading fitsio-1.1.1.tar.gz (5.0 MB)
     |████████████████████████████████| 5.0 MB 3.1 MB/s 
Requirement already satisfied, skipping upgrade: numpy in /usr/local/lib/python2.7/dist-packages (from fitsio) (1.14.0)
Building wheels for collected packages: fitsio
  Building wheel for fitsio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rIbaaq
       cwd: /tmp/pip-install-Fr2xmK/fitsio/
  Complete output (113 lines):
  /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/fitsio
  copying fitsio/util.py -> build/lib.linux-x86_64-2.7/fitsio
  copying fitsio/test.py -> build/lib.linux-x86_64-2.7/fitsio
  copying fitsio/fitslib.py -> build/lib.linux-x86_64-2.7/fitsio
  copying fitsio/__init__.py -> build/lib.linux-x86_64-2.7/fitsio
  copying fitsio/header.py -> build/lib.linux-x86_64-2.7/fitsio
  creating build/lib.linux-x86_64-2.7/fitsio/hdu
  copying fitsio/hdu/table.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
  copying fitsio/hdu/base.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
  copying fitsio/hdu/__init__.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
  copying fitsio/hdu/image.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
  running build_ext
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/putcols.c
  Hunk #1 succeeded at 157 (offset -1 lines).
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/putcols.c
  Hunk #1 succeeded at 157 (offset -1 lines).
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/fitsio.h
  Hunk #1 succeeded at 806 (offset 9 lines).
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/fitsio.h
  Hunk #1 succeeded at 806 (offset 9 lines).
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/configure
  Hunk #1 succeeded at 711 with fuzz 2 (offset 3 lines).
  Hunk #2 succeeded at 1345 (offset 5 lines).
  Hunk #3 succeeded at 2337 (offset 84 lines).
  Hunk #4 succeeded at 5200 (offset 117 lines).
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/configure
  Hunk #1 succeeded at 711 with fuzz 2 (offset 3 lines).
  Hunk #2 succeeded at 1345 (offset 5 lines).
  Hunk #3 succeeded at 2337 (offset 84 lines).
  Hunk #4 succeeded at 5200 (offset 117 lines).
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/configure.in
  Hunk #1 succeeded at 52 (offset 10 lines).
  Hunk #2 succeeded at 610 (offset 21 lines).
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/configure.in
  Hunk #1 succeeded at 52 (offset 10 lines).
  Hunk #2 succeeded at 610 (offset 21 lines).
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/fitscore.c
  Hunk #1 succeeded at 186 (offset 4 lines).
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/fitscore.c
  Hunk #1 succeeded at 186 (offset 4 lines).
  checking file build/temp.linux-x86_64-2.7/cfitsio3470/drvrnet.c
  patching file build/temp.linux-x86_64-2.7/cfitsio3470/drvrnet.c
  checking build system type... x86_64-pc-linux-gnu
  checking host system type... x86_64-pc-linux-gnu
  checking target system type... x86_64-pc-linux-gnu
  checking for gcc... x86_64-linux-gnu-gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables...
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether x86_64-linux-gnu-gcc accepts -g... yes
  checking for x86_64-linux-gnu-gcc option to accept ISO C89... none needed
  checking how to run the C preprocessor... x86_64-linux-gnu-gcc -E
  checking for grep that handles long lines and -e... /bin/grep
  checking for egrep... /bin/grep -E
  checking for ANSI C header files... yes
  checking for sys/types.h... yes
  checking for sys/stat.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for memory.h... yes
  checking for strings.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for unistd.h... yes
  checking for main in -lbz2... no
  configure: error: Unable to locate bz2 library needed when enabling bzip2 support; try specifying the path
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 289, in <module>
      cmdclass={"build_ext": build_ext_subclass}
    File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/lib/python2.7/dist-packages/wheel/bdist_wheel.py", line 179, in run
      self.run_command('build')
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
      self.run_command(cmd_name)
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 72, in run
      build_ext.run(self)
    File "/usr/local/lib/python2.7/dist-packages/setuptools/command/build_ext.py", line 75, in run
      _build_ext.run(self)
    File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/old_build_ext.py", line 186, in run
      _build_ext.build_ext.run(self)
    File "/usr/lib/python2.7/distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 100, in build_extensions
      RANLIB=self.compiler.ranlib,
    File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 227, in configure_cfitsio
      "could not configure cfitsio %s" % self.cfitsio_version)
  ValueError: could not configure cfitsio 3470
  ----------------------------------------
  ERROR: Failed building wheel for fitsio
  Running setup.py clean for fitsio
Failed to build fitsio
Installing collected packages: fitsio
  Attempting uninstall: fitsio
    Found existing installation: fitsio 0.9.11
    Uninstalling fitsio-0.9.11:
      Successfully uninstalled fitsio-0.9.11
    Running setup.py install for fitsio ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r3Z0xt/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/fitsio
         cwd: /tmp/pip-install-Fr2xmK/fitsio/
    Complete output (115 lines):
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/fitsio
    copying fitsio/util.py -> build/lib.linux-x86_64-2.7/fitsio
    copying fitsio/test.py -> build/lib.linux-x86_64-2.7/fitsio
    copying fitsio/fitslib.py -> build/lib.linux-x86_64-2.7/fitsio
    copying fitsio/__init__.py -> build/lib.linux-x86_64-2.7/fitsio
    copying fitsio/header.py -> build/lib.linux-x86_64-2.7/fitsio
    creating build/lib.linux-x86_64-2.7/fitsio/hdu
    copying fitsio/hdu/table.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
    copying fitsio/hdu/base.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
    copying fitsio/hdu/__init__.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
    copying fitsio/hdu/image.py -> build/lib.linux-x86_64-2.7/fitsio/hdu
    running build_ext
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/putcols.c
    Hunk #1 succeeded at 157 (offset -1 lines).
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/putcols.c
    Hunk #1 succeeded at 157 (offset -1 lines).
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/fitsio.h
    Hunk #1 succeeded at 806 (offset 9 lines).
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/fitsio.h
    Hunk #1 succeeded at 806 (offset 9 lines).
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/configure
    Hunk #1 succeeded at 711 with fuzz 2 (offset 3 lines).
    Hunk #2 succeeded at 1345 (offset 5 lines).
    Hunk #3 succeeded at 2337 (offset 84 lines).
    Hunk #4 succeeded at 5200 (offset 117 lines).
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/configure
    Hunk #1 succeeded at 711 with fuzz 2 (offset 3 lines).
    Hunk #2 succeeded at 1345 (offset 5 lines).
    Hunk #3 succeeded at 2337 (offset 84 lines).
    Hunk #4 succeeded at 5200 (offset 117 lines).
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/configure.in
    Hunk #1 succeeded at 52 (offset 10 lines).
    Hunk #2 succeeded at 610 (offset 21 lines).
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/configure.in
    Hunk #1 succeeded at 52 (offset 10 lines).
    Hunk #2 succeeded at 610 (offset 21 lines).
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/fitscore.c
    Hunk #1 succeeded at 186 (offset 4 lines).
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/fitscore.c
    Hunk #1 succeeded at 186 (offset 4 lines).
    checking file build/temp.linux-x86_64-2.7/cfitsio3470/drvrnet.c
    patching file build/temp.linux-x86_64-2.7/cfitsio3470/drvrnet.c
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking target system type... x86_64-pc-linux-gnu
    checking for gcc... x86_64-linux-gnu-gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether x86_64-linux-gnu-gcc accepts -g... yes
    checking for x86_64-linux-gnu-gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... x86_64-linux-gnu-gcc -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for main in -lbz2... no
    configure: error: Unable to locate bz2 library needed when enabling bzip2 support; try specifying the path
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 289, in <module>
        cmdclass={"build_ext": build_ext_subclass}
      File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run
        self.run_command('build')
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
        self.run_command(cmd_name)
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 72, in run
        build_ext.run(self)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/build_ext.py", line 75, in run
        _build_ext.run(self)
      File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "/usr/lib/python2.7/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 100, in build_extensions
        RANLIB=self.compiler.ranlib,
      File "/tmp/pip-install-Fr2xmK/fitsio/setup.py", line 227, in configure_cfitsio
        "could not configure cfitsio %s" % self.cfitsio_version)
    ValueError: could not configure cfitsio 3470
    ----------------------------------------
  Rolling back uninstall of fitsio
  Moving to /usr/local/lib/python2.7/dist-packages/fitsio-0.9.11.egg-info
   from /usr/local/lib/python2.7/dist-packages/~itsio-0.9.11.egg-info
  Moving to /usr/local/lib/python2.7/dist-packages/fitsio/
   from /usr/local/lib/python2.7/dist-packages/~itsio
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Fr2xmK/fitsio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r3Z0xt/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/fitsio Check the logs for full command output.
`

从错误输出:

configure: error: Unable to locate bz2 library needed when enabling bzip2 support; try specifying the path

您很可能需要 bz2 库及其开发头文件。如何安装这些取决于您的 OS。例如在 Debian/Ubuntu 上是:

$ sudo apt-get install libbz2-dev