Skip to content

Cannot install from pip on Msys2 mingw64 #7222

@mbasaglia

Description

@mbasaglia

What did you do?

I followed the steps in https://pillow.readthedocs.io/en/latest/installation.html
The zlib package (mingw-w64-x86_64-zlib ) is installed correctly:

$ file /mingw64/include/zlib.h
/mingw64/include/zlib.h: C source, ASCII text

I ran this command as per the documentation:

$ CFLAGS="-I/mingw64/include" python3 -m pip install --upgrade Pillow --no-binary :all:

What did you expect to happen?

To install correctly

What actually happened?

It failed:

Collecting Pillow
  Using cached Pillow-9.5.0.tar.gz (50.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: Pillow
  Building wheel for Pillow (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for Pillow (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [198 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.mingw_x86_64-cpython-310
      creating build/lib.mingw_x86_64-cpython-310/PIL
[skipping a bunch of useless stuff]
      running build_ext


      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.

      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html

      Traceback (most recent call last):
        File "<string>", line 993, in <module>
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 343, in run
          self.run_command("build")
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
          self.build_extensions()
        File "<string>", line 809, in build_extensions
      __main__.RequiredDependencyException: zlib

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "C:\msys64\mingw64\lib\python3.10\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\msys64\mingw64\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 "C:\msys64\mingw64\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 "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 416, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir
          self.run_setup()
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "C:/msys64/tmp/pip-build-env-ol6lvvu4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 1010, in <module>
      __main__.RequiredDependencyException:

      The headers or library files could not be found for zlib,
      a required dependency when compiling Pillow from source.

      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html


      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for Pillow
Failed to build Pillow
ERROR: Could not build wheels for Pillow, which is required to install pyproject.toml-based projects

The result is the same with--no-cache-dir

What are your OS, Python and Pillow versions?

  • OS: MSYS2 MINGW64
  • Python: Python 3.10.12 (/mingw64/bin/python)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions