Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing python-ldap in a virtualenv on Windows

I'm working on a Django project that is using an ldap authentication module. This is working on our server but I am running into issues getting this running on my windows dev machine.

My environment is using virtualevn and when trying to install pip python-ldap I receive the following message:

error: Unable to find vcvarsall.bat

Does anyone have any idea what could be going wrong?

like image 222
james_dean Avatar asked Feb 25 '13 15:02

james_dean


People also ask

How do I install virtualenv in Python?

Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip. Unix/macOS python3 -m pip install --user virtualenv Windows py -m pip install --user virtualenv Creating a virtual environment¶

How do I install Py-LDAP on Windows?

Unofficial packages for Windows are available on Christoph Gohlke’s page. The CVS repository of FreeBSD contains the package py-ldap You can install directly with pip: python-ldap is built and installed using the Python setuptools. From a source repository:

How to create a virtual environment while developing Python applications?

It is always recommended to use a virtual environment while developing Python applications. To create a virtual environment, go to your project’s directory and run venv. If you are using Python 2, replace venvwith virtualenvin the below commands. Unix/macOS python3 -m venv env

What is required to install Python-LDAP?

Furthermore, python-ldap requires the modules pyasn1 and pyasn1-modules . pip will install these automatically. Because distributions seem to be all over the place, this page tries to list all the current ones we know of. Note that the python-ldap team is not responsible for the binary packages except the sources you can grab from the PyPI page.


2 Answers

To expand on @Brandon's answer, to install using the pre-built wheel:

  1. Ensure you have pip 19.2+ installed:

    $ pip --version
    pip 19.2.3
    
  2. Check your Python version and architecture (32/64 bit) https://stackoverflow.com/a/10966396/1026:

    $ python -c 'import sys; print(sys.version)'
    3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
    
  3. Download the matching pre-built *.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

    For example given the above Python I picked "python_ldap‑3.2.0‑cp37‑cp37m‑win_amd64.whl"

  4. Install it with:

    pip install path\to\your.whl
    
like image 57
Nickolay Avatar answered Sep 20 '22 02:09

Nickolay


Unfortunately, many Python modules have trouble installing on Windows. The error you're receiving is one that I was never able to get fixed, even given the vast amount of information available on the web. Give this link a try for a pre-compiled version: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

like image 32
Brandon Avatar answered Sep 19 '22 02:09

Brandon