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.
Your Python version is 3.13 and it is not compatible with pillow 10.3.0. Pillow 10.3.0 supports Python 3.8 - 3.12. There are no wheels for Python 3.13.
So why did pip install pillow
work? Installing a package without specifying a version usually attempts to install the latest release. So pip install pillow
will give you the stable release of pillow which supports Python 3.13.
Always look at the supported python versions of specific packages and verify that the package version you are trying to install is compatible.