[Python] Python Package Installation Fails: 'Getting requirements to build wheel did not run...

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    In my python projects I create a list of required packages by pip freeze > requirements.txt it automatically list the packages with version. But after a while when I reinstall the package or trying to run other people project I have to install the dependencis with pip install -r requirements.txt. In this process some of the packages(For example, Pillow, numpy, etc) can't install the specific version that listed. By removing the version number it can install successfully.

    In my current case, My project have requirement of pillow==10.3.0 but it shows the following error.

    Collecting pillow==10.3.0 (from -r requirements.txt (line 6))
    Using cached pillow-10.3.0.tar.gz (46.6 MB)
    Installing build dependencies ... done
    Getting requirements to build wheel ... error
    error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> [21 lines of output]
    Traceback (most recent call last):
    File "D:\LMS\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
    main()
    ~~~~^^
    File "D:\LMS\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\LMS\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel return hook(config_settings)
    File "C:\Users\wo\AppData\Local\Temp\pip-build-env-bxsls9dh\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\wo\AppData\Local\Temp\pip-build-env-bxsls9dh\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
    self.run_setup()
    ~~~~~~~~~~~~~~^^
    File "C:\Users\wo\AppData\Local\Temp\pip-build-env-bxsls9dh\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
    exec(code, locals())
    ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 33, in <module>
    File "<string>", line 27, in get_version
    KeyError: '__version__'
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error

    × Getting requirements to build wheel 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.



    Then I tried to install the package with the same version manually and still fails. So, I installed pillow without version specification and it installed successfully.

    (venv) D:\LMS>pip install pillow
    Collecting pillow
    Using cached pillow-11.1.0-cp313-cp313-win_amd64.whl.metadata (9.3 kB)
    Using cached pillow-11.1.0-cp313-cp313-win_amd64.whl (2.6 MB)
    Installing collected packages: pillow
    Successfully installed pillow-11.1.0


    I face this situation often, so I want to know why this happens or what to do in this situations.

    Continue reading...

Compartilhe esta Página