Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install from pip on Msys2 mingw64 #7222

Closed
mbasaglia opened this issue Jun 20, 2023 · 5 comments · Fixed by #7224
Closed

Cannot install from pip on Msys2 mingw64 #7222

mbasaglia opened this issue Jun 20, 2023 · 5 comments · Fixed by #7224

Comments

@mbasaglia
Copy link

mbasaglia commented Jun 20, 2023

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)
@radarhere radarhere added Installation Usually a problem with … Windows Build and removed Installation Usually a problem with … labels Jun 20, 2023
@radarhere
Copy link
Member

There was a similar report in #5868. It looks like the solution there was to create a virtual environment?

A suggestion from #4649 is to try pacman -S mingw-w64-x86_64-python3-pillow

@nulano
Copy link
Contributor

nulano commented Jun 20, 2023

I think #7131 is relevant here:

MinGW is currently failing in main - https://github.com/python-pillow/Pillow/actions/runs/4861154081

https://www.msys2.org/docs/python/ states

setuptools >= 60.0 is currently incompatible with MSYS2. You can set export SETUPTOOLS_USE_DISTUTILS=stdlib to work around the issue. We are currently working on restoring compatibility.

Adding in SETUPTOOLS_USE_DISTUTILS="stdlib" fixes the problem.


There was a similar report in #5868. It looks like the solution there was to create a virtual environment?

I think the question there was how to install Pillow in a virtual environment, and the issue was some confusion with PATH.

@radarhere
Copy link
Member

@mbasaglia does https://www.msys2.org/docs/python/

setuptools >= 60.0 is currently incompatible with MSYS2. You can set export SETUPTOOLS_USE_DISTUTILS=stdlib to work around the issue. We are currently working on restoring compatibility.

resolve the problem for you? If so, we can update our documentation to include that.

@mbasaglia
Copy link
Author

yea SETUPTOOLS_USE_DISTUTILS=stdlib seems to fix it

@radarhere
Copy link
Member

Thanks. I've created #7224 to resolve this by documenting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants