python-buildpack: python3.8.12 - fatal error: Python.h: No such file or directory
What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?
cf8.exe version 8.2.0+fd8fbca64.2022-02-09
What version of the buildpack you are using?
https://github.com/cloudfoundry/python-buildpack#v1.7.49
What did you expect to happen?
Install xmlsec succesfully in python 3.8.12 - https://github.com/mehcode/python-xmlsec
What was the actual behavior?
- Able to install xmlsec in python 3.6.15
- Unable to install xmlsec in python 3.8.12 with error log below

Steps to reproduce:
git clone https://github.com/sunny-repo88/cf-python-buildpack-bug; cd cf-python-buildpack-bug;cf push
Please confirm where necessary:
- I have included a log output
- My log includes an error message
- I have included steps for reproduction
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 23 (9 by maintainers)
Commits related to this issue
- Explicitly pin setuptools to fix buildpack build error Droplet builds using the python buildpack stopped working caused by an error thrown while building pycurl from source. All buildpack versions (... — committed to alphagov/notifications-api by rjbaker 2 years ago
- pinning setuptools to working version per github issue: https://github.com/cloudfoundry/python-buildpack/issues/574 — committed to GSA/catalog.data.gov by btylerburton 2 years ago
- pinning setuptools to working version per github issue: https://github.com/cloudfoundry/python-buildpack/issues/574 — committed to GSA/catalog.data.gov by btylerburton 2 years ago
- supply: remove pre-installing mercurial * There's no documentation that suggests that while installing from a remote url via a VCS like `hg`, the `mercurial` package should be pre-installed. [Pip doc... — committed to cloudfoundry/python-buildpack by arjun024 2 years ago
- supply: remove pre-installing mercurial * There's no documentation that suggests that while installing from a remote url via a VCS like `hg`, the `mercurial` package should be pre-installed. [Pip doc... — committed to cloudfoundry/python-buildpack by arjun024 2 years ago
- Update python buildpack We are seeing an error when trying to build on cloudfoundry - `ERR ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory` (similar issue to this[1]). Thi... — committed to uktrade/enquiry-mgmt-tool by deleted user 2 years ago
- Update python buildpack We are seeing an error when trying to build on cloudfoundry - `ERR ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory` (similar issue to this[1]). Thi... — committed to uktrade/enquiry-mgmt-tool by deleted user 2 years ago
- Update python buildpack (#325) We are seeing an error when trying to build on cloudfoundry - `ERR ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory` (similar issue to this... — committed to uktrade/enquiry-mgmt-tool by Harriethw 2 years ago
- Remove setuptools and upgrade Python buildpack A previous bug has been fixed in this buildpack as per this issue[1] so we no longer need to put setuptools in requirements file. [1]https://github.com... — committed to uktrade/data-hub-api by deleted user 2 years ago
We are able to reproduce the underlying issue a few different ways, and we have a fix for the root case on the
developbranch.You can try this out by using the
developbranch while pushing your app:Please try this out and let us know if it works (or doesn’t work).
We expect to release a new version of the buildpack shortly, but any feedback before then would be welcome.
Like @Deviaruna said, this issue seems to be caused by a setuptools version downloaded as a transitive dependency by users’ direct dependencies (e.g. psycopg2), and not due to a dependency provided by the buildpack. For the same app, I can see this same issue occurring while using an older version. I’m not sure buildpacks have control over it though I can look into it if there’s something we can do.
@sunny-repo88 For https://github.com/sunny-repo88/cf-python-buildpack-withoutapt, this works for me:
Edit: fix link
Confirmed. Issue resolved in https://github.com/cloudfoundry/python-buildpack/releases/tag/v1.7.58.
Thanks to the team!
I can confirm that xmlsec now compiles correctly using the repro steps above. Thanks for the quick fix!
@mrogaski @amhuber yes, agreed. We believe that when an application depends on a project that uses PEP-517 Build Isoloation - like
krb5has done since its creation - and that project has a build-dependency onsetuptoolswithout an upper limit (likekrb5) then the latest version ofsetuptools(i.e.65.2.0) is downloaded and we observe the same issue as if the app hadsetuptoolsas a direct dependency.We are actively exploring a fix for the root cause -
setuptools >= 65.2.0not working with the python buildpack - as well as any potential workarounds to assist with pinning the version ofsetuptoolswhen it is pulled in as a transitive dependency. We will keep this thread updated with our investigation.Keeping setuptools permanently pinned to an old version isn’t going to work forever. I’m hoping there are some updates that can be made to the buildpack to adjust to whatever setuptools is expecting. It looks like https://github.com/heroku/heroku-buildpack-python/commit/b2dfe7397bf2f57b70799954277dd01a9c034432 might be related.
Hi All, We were facing the same issue in multiple projects. One of our colleague has figured out the reason behind the crash. One transient package upgraded i.e. setuptools from 65.1 to 65.2 version. If you could downgrade setuptools to 65.1.0, that would work. Thanks
I face the same issue. I use Python 3.8.10 & psycopg2 2.9.3 and “changed nothing” since 8th Aug.
@arjun024 , thanks for quick response. I have another example without using apt buildpack
Steps to reproduce:
Behaviour:
We are able to install both example in fresh new docker environment - python:3.8-buster
We are also seeing this on our environments. We haven’t figured out what changed yet, but apps that were previously deploying are now getting this error, and the apt.yml packages were set up correctly to support compilation of xmlsec.