Error installing django-auth-ldap on Ubuntu 20.04. Fails on python-ldap dependency. #8648

Closed
opened 2025-12-29 20:39:18 +01:00 by adam · 2 comments
Owner

Originally created by @k-masters on GitHub (Sep 19, 2023).

NetBox version

v3.6.1

Python version

3.11

Steps to Reproduce

  1. Install required system packages
  2. Activate virtual environment
  3. Install django-auth-ldap

Expected Behavior

django-ldap-auth should install successfully along with all required dependencies.

Observed Behavior

Required system packages are installed

netbox@dhqnetbox:~$ sudo apt install -y libldap2-dev libsasl2-dev libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libldap2-dev is already the newest version (2.4.49+dfsg-2ubuntu1.9).
libsasl2-dev is already the newest version (2.1.27+dfsg-2ubuntu0.1).
libssl-dev is already the newest version (1.1.1f-1ubuntu2.19).
0 upgraded, 0 newly installed, 0 to remove and 45 not upgraded.

Installation fails when building the wheel for python-ldap.

netbox@dhqnetbox:~$ source /opt/netbox/venv/bin/activate
(venv) netbox@dhqnetbox:~$ pip3 install django-auth-ldap
Collecting django-auth-ldap
  Obtaining dependency information for django-auth-ldap from https://files.pythonhosted.org/packages/50/4c/74e2266e8a05a61b2c6be5bc17d03d0fb4a5b0ac881fa0deb6c7162f910e/django_auth_ldap-4.5.0-py3-none-any.whl.metadata
  Using cached django_auth_ldap-4.5.0-py3-none-any.whl.metadata (7.2 kB)
Requirement already satisfied: Django>=3.2 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from django-auth-ldap) (4.2.5)
Collecting python-ldap>=3.1 (from django-auth-ldap)
  Using cached python-ldap-3.4.3.tar.gz (377 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: asgiref<4,>=3.6.0 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from Django>=3.2->django-auth-ldap) (3.7.2)
Requirement already satisfied: sqlparse>=0.3.1 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from Django>=3.2->django-auth-ldap) (0.4.4)
Requirement already satisfied: pyasn1>=0.3.7 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from python-ldap>=3.1->django-auth-ldap) (0.5.0)
Collecting pyasn1-modules>=0.1.5 (from python-ldap>=3.1->django-auth-ldap)
  Using cached pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
Using cached django_auth_ldap-4.5.0-py3-none-any.whl (20 kB)
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
  ╰─> [97 lines of output]
      /tmp/pip-build-env-pjp95lqa/overlay/lib/python3.11/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!

              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.

              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      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/pkginfo.py -> build/lib.linux-x86_64-cpython-311/ldap
      copying Lib/ldap/syncrepl.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/sasl.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/cidict.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/ldapobject.py -> build/lib.linux-x86_64-cpython-311/ldap
      copying Lib/ldap/__init__.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/functions.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/resiter.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/modlist.py -> build/lib.linux-x86_64-cpython-311/ldap
      copying Lib/ldap/filter.py -> build/lib.linux-x86_64-cpython-311/ldap
      creating 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/readentry.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
      copying Lib/ldap/controls/pagedresults.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/sessiontrack.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/psearch.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/simple.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/vlv.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
      creating build/lib.linux-x86_64-cpython-311/ldap/extop
      copying Lib/ldap/extop/__init__.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/passwd.py -> build/lib.linux-x86_64-cpython-311/ldap/extop
      creating 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/__init__.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/tokenizer.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
      x86_64-linux-gnu-gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.3 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -I/opt/netbox-3.6.1/venv/include -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/x86_64-linux-gnu-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
(venv) netbox@dhqnetbox:~$
Originally created by @k-masters on GitHub (Sep 19, 2023). ### NetBox version v3.6.1 ### Python version 3.11 ### Steps to Reproduce 1. Install required system packages 2. Activate virtual environment 3. Install django-auth-ldap ### Expected Behavior django-ldap-auth should install successfully along with all required dependencies. ### Observed Behavior ### Required system packages are installed ``` netbox@dhqnetbox:~$ sudo apt install -y libldap2-dev libsasl2-dev libssl-dev Reading package lists... Done Building dependency tree Reading state information... Done libldap2-dev is already the newest version (2.4.49+dfsg-2ubuntu1.9). libsasl2-dev is already the newest version (2.1.27+dfsg-2ubuntu0.1). libssl-dev is already the newest version (1.1.1f-1ubuntu2.19). 0 upgraded, 0 newly installed, 0 to remove and 45 not upgraded. ``` ### Installation fails when building the wheel for python-ldap. ``` netbox@dhqnetbox:~$ source /opt/netbox/venv/bin/activate (venv) netbox@dhqnetbox:~$ pip3 install django-auth-ldap Collecting django-auth-ldap Obtaining dependency information for django-auth-ldap from https://files.pythonhosted.org/packages/50/4c/74e2266e8a05a61b2c6be5bc17d03d0fb4a5b0ac881fa0deb6c7162f910e/django_auth_ldap-4.5.0-py3-none-any.whl.metadata Using cached django_auth_ldap-4.5.0-py3-none-any.whl.metadata (7.2 kB) Requirement already satisfied: Django>=3.2 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from django-auth-ldap) (4.2.5) Collecting python-ldap>=3.1 (from django-auth-ldap) Using cached python-ldap-3.4.3.tar.gz (377 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: asgiref<4,>=3.6.0 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from Django>=3.2->django-auth-ldap) (3.7.2) Requirement already satisfied: sqlparse>=0.3.1 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from Django>=3.2->django-auth-ldap) (0.4.4) Requirement already satisfied: pyasn1>=0.3.7 in /opt/netbox-3.6.1/venv/lib/python3.11/site-packages (from python-ldap>=3.1->django-auth-ldap) (0.5.0) Collecting pyasn1-modules>=0.1.5 (from python-ldap>=3.1->django-auth-ldap) Using cached pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB) Using cached django_auth_ldap-4.5.0-py3-none-any.whl (20 kB) 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 ╰─> [97 lines of output] /tmp/pip-build-env-pjp95lqa/overlay/lib/python3.11/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg` !! ******************************************************************************** The license_file parameter is deprecated, use license_files instead. By 2023-Oct-30, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! parsed = self.parsers.get(option_name, lambda x: x)(value) 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/pkginfo.py -> build/lib.linux-x86_64-cpython-311/ldap copying Lib/ldap/syncrepl.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/sasl.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/cidict.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/ldapobject.py -> build/lib.linux-x86_64-cpython-311/ldap copying Lib/ldap/__init__.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/functions.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/resiter.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/modlist.py -> build/lib.linux-x86_64-cpython-311/ldap copying Lib/ldap/filter.py -> build/lib.linux-x86_64-cpython-311/ldap creating 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/readentry.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 copying Lib/ldap/controls/pagedresults.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/sessiontrack.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/psearch.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/simple.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/vlv.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 creating build/lib.linux-x86_64-cpython-311/ldap/extop copying Lib/ldap/extop/__init__.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/passwd.py -> build/lib.linux-x86_64-cpython-311/ldap/extop creating 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/__init__.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/tokenizer.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 x86_64-linux-gnu-gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.3 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -I/opt/netbox-3.6.1/venv/include -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/x86_64-linux-gnu-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 (venv) netbox@dhqnetbox:~$ ```
adam closed this issue 2025-12-29 20:39:18 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 19, 2023):

This is not a NetBox issue. Please consult the django-auth-ldap documentation for installation help.

@jeremystretch commented on GitHub (Sep 19, 2023): This is not a NetBox issue. Please consult the `django-auth-ldap` documentation for installation help.
Author
Owner

@k-masters commented on GitHub (Sep 19, 2023):

Eventually found my issue. I needed to install the system package python3.11-dev

@k-masters commented on GitHub (Sep 19, 2023): Eventually found my issue. I needed to install the system package `python3.11-dev`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8648