2

I've installed flask, flask_login, and ldap in the virtualenv for my flask package (to authenticate ldap users with the usernames & passwords of the other users at my company).

When I run my flask app, I get "AttributeError: 'module' object has no attribute 'initialize'"

I'm tried "pip install python-ldap" but I get a red error (sandwiched between other white text) that reads: "Failed building wheel for python-ldap"

I have thoroughly examined these: How to install python-ldap on a python 2.7 virtualenv on windows without compiling

Installing python-ldap in a virtualenv on Windows

https://www.python-ldap.org/docs.html

https://www.linuxjournal.com/article/6988?page=0,1

to no avail. I've had this error for days now...

(also:

pip install openldap

gives:

Collecting openldap Could not find a version that satisfies the requirement openldap (from versions: ) No matching distribution found for openldap

...(in and outside of my venv) if that information helps)

I had this error last week and after switching work computers, I recreated the virtualenv and installed all of the other packages and dependencies successfully.

my requirements.txt file contains these lines after a line of git stuff:

click==6.7

Flask==0.12.2

Flask-Login==0.4.0

itsdangerous==0.24

Jinja2==2.9.6

ldap==1.0.2

ldap3==2.2.4

MarkupSafe==1.0

pyasn1==0.2.3

Werkzeug==0.12.2

Has anyone successfully installed python-ldap into a flask virtualenv with windows? If so... how?!

Eve
  • 86
  • 1
  • 1
  • 6

2 Answers2

5

Go to:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

download python_ldap-2.4.38-cp27-cp27m-win_amd64.whl in the same directory that your venv folder is listed under

(ex.)

/myrepo
    /myapp
      /myapp
      /venv
      /run.py
      /python_ldap-2.4.38-cp27-cp27m-win_amd64.whl

install the .whl file while inside of your venv

venv\Scripts\activate

pip install python_ldap-2.4.38-cp27-cp27m-win_amd64.whl

Voila!

Eve
  • 86
  • 1
  • 1
  • 6
0

The error

ERROR: Failed building wheel for python-ldap

can occur for several reasons. You actually have to look at what happened above this line. In my case, I just had to install missing dependencies to build python-ldap. You can look them up here. For CentOS 8, I had to install:

sudo dnf install openldap-devel python3-devel gcc

to make

python3 -m pip install --user python-ldap -U

work.

stackprotector
  • 10,498
  • 4
  • 35
  • 64