Skip to content

error installing python-ldap 3.4.4 on amazon linux 2 #569

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

Open
ashterenberg-paramount opened this issue Jun 5, 2024 · 5 comments
Open

Comments

@ashterenberg-paramount
Copy link

If you found a bug in python-ldap, or would request a new feature,
this is the place to let us know.

Please describe the issue and your environment here.
error install python-ldap 3.4.4 on Amazon Linux 2 using python 3.11

Issue description:

All pre-reqs installed, ie

yum groupinstall "Development tools"

yum install openldap-devel python-devel

rpm -qa | grep openldap
openldap-2.4.57-6.amzn2023.0.6.x86_64
openldap-devel-2.4.57-6.amzn2023.0.6.x86_64
openldap-compat-2.4.57-6.amzn2023.0.6.x86_64
openldap-clients-2.4.57-6.amzn2023.0.6.x86_64

Running python3.11 -m pip install python-ldap
results in

  gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.4 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -I/usr/include/python3.11 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-cpython-311/Modules/LDAPObject.o
  In file included from Modules/LDAPObject.c:3:
  Modules/common.h:9:10: fatal error: Python.h: No such file or directory
      9 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/gcc' failed with exit code 1

Steps to reproduce:

python3.11 -m pip install python-ldap

Collecting python-ldap
Using cached python-ldap-3.4.4.tar.gz (377 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pyasn1>=0.3.7 in /usr/local/lib/python3.11/site-packages (from python-ldap) (0.6.0)
Requirement already satisfied: pyasn1-modules>=0.1.5 in /usr/local/lib/python3.11/site-packages (from python-ldap) (0.4.0)
Building wheels for collected packages: python-ldap
Building wheel for python-ldap (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for python-ldap (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [83 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
copying Lib/ldapurl.py -> build/lib.linux-x86_64-cpython-311
copying Lib/ldif.py -> build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/sasl.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/resiter.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/pkginfo.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/modlist.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/logger.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/ldapobject.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/functions.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/filter.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/dn.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/constants.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/compat.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/cidict.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/asyncsearch.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/async.py -> build/lib.linux-x86_64-cpython-311/ldap
copying Lib/ldap/init.py -> build/lib.linux-x86_64-cpython-311/ldap
creating build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/vlv.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/sss.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/simple.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/sessiontrack.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/readentry.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/pwdpolicy.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/psearch.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/ppolicy.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/pagedresults.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/openldap.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/libldap.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/deref.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
copying Lib/ldap/controls/init.py -> build/lib.linux-x86_64-cpython-311/ldap/controls
creating build/lib.linux-x86_64-cpython-311/ldap/extop
copying Lib/ldap/extop/passwd.py -> build/lib.linux-x86_64-cpython-311/ldap/extop
copying Lib/ldap/extop/dds.py -> build/lib.linux-x86_64-cpython-311/ldap/extop
copying Lib/ldap/extop/init.py -> build/lib.linux-x86_64-cpython-311/ldap/extop
creating build/lib.linux-x86_64-cpython-311/ldap/schema
copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-cpython-311/ldap/schema
copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-cpython-311/ldap/schema
copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-cpython-311/ldap/schema
copying Lib/ldap/schema/init.py -> build/lib.linux-x86_64-cpython-311/ldap/schema
creating build/lib.linux-x86_64-cpython-311/slapdtest
copying Lib/slapdtest/_slapdtest.py -> build/lib.linux-x86_64-cpython-311/slapdtest
copying Lib/slapdtest/init.py -> build/lib.linux-x86_64-cpython-311/slapdtest
running egg_info
writing Lib/python_ldap.egg-info/PKG-INFO
writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
writing requirements to Lib/python_ldap.egg-info/requires.txt
writing top-level names to Lib/python_ldap.egg-info/top_level.txt
reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'Doc/.build'
adding license file 'LICENCE'
writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
creating build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/README -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/ca.conf -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/ca.pem -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/client.conf -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/client.key -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/client.pem -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/gencerts.sh -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/gennssdb.sh -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/server.conf -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/server.key -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
copying Lib/slapdtest/certs/server.pem -> build/lib.linux-x86_64-cpython-311/slapdtest/certs
running build_ext
building '_ldap' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/Modules
gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -ftree-vectorize -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.4 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -I/usr/include/python3.11 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-cpython-311/Modules/LDAPObject.o
In file included from Modules/LDAPObject.c:3:
Modules/common.h:9:10: fatal error: Python.h: No such file or directory
9 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

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

Operating system:
Amazon Linux 2
Python version:
3.11

python-ldap version:
3.4.4

@quanah
Copy link
Contributor

quanah commented Jun 5, 2024

Looks like you didn't install the python development package.

@quanah
Copy link
Contributor

quanah commented Jun 5, 2024

Modules/common.h:9:10: fatal error: Python.h: No such file or directory 9 | #include "Python.h" | ^~~~~~~~~~

@ashterenberg-paramount
Copy link
Author

it is there

yum install openldap-devel python-devel

Amazon Linux 2023 repository 16 kB/s | 3.6 kB 00:00
Amazon Linux 2023 Kernel Livepatch repository 12 kB/s | 2.9 kB 00:00
Package openldap-devel-2.4.57-6.amzn2023.0.6.x86_64 is already installed.
Package python3-devel-3.9.16-1.amzn2023.0.7.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

@quanah
Copy link
Contributor

quanah commented Jun 5, 2024

Then there is something wrong either with the package (it didn't install Python.h) or incorrect with your gcc search path, etc. This is not a python-ldap issue.

@ashterenberg-paramount
Copy link
Author

I figured it out. You were on the right track. Your instructions for building from source (https://www.python-ldap.org/en/latest/installing.html#installing-from-source) are somewhat incomplete. You should add the following:

Installing python3-dev/devel does not automatically cover all minor versions of python3.
For example, if you are using python 3.11 you may need to install python3.11-dev / python3.11-devel.

This was adopted from the top answer to https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory

Thanks for your help!

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

No branches or pull requests

2 participants