title: virtualenv python-ldap install error
body: <p>Please don't call this a duplicate.  </p>
  
  <p>All the answers have so far only 'solved' the problem by installing the ldap and other development packages globally, which doesn't solve the problem of not being able to install the python-ldap package in the virtual environment.  </p>
  
  <p>Examples include: 
  <a href="https://stackoverflow.com/questions/18134826/how-do-i-install-python-ldap-in-a-virtualenv-on-ubuntu">How do I install python-ldap in a virtualenv on Ubuntu?</a></p>
  
  <pre><code>sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
  </code></pre>
  
  <p>I am using ubuntu 14.04, python 2.7 and flask in my virtual environment.</p>
  
  <p>When I run <code>pip install python-ldap</code>, I receive the following error.</p>
  
  <pre><code>    copying Lib/ldap/schema/__init__.py -&gt; build/lib.linux-x86_64-2.7/ldap/schema
  copying Lib/ldap/schema/models.py -&gt; build/lib.linux-x86_64-2.7/ldap/schema
  copying Lib/ldap/schema/subentry.py -&gt; build/lib.linux-x86_64-2.7/ldap/schema
  copying Lib/ldap/schema/tokenizer.py -&gt; build/lib.linux-x86_64-2.7/ldap/schema
  copying Lib/ldap/syncrepl.py -&gt; build/lib.linux-x86_64-2.7/ldap
  file Lib/ldap.py (for module ldap) not found
  file Lib/ldap/controls.py (for module ldap.controls) not found
  file Lib/ldap/extop.py (for module ldap.extop) not found
  file Lib/ldap/schema.py (for module ldap.schema) not found
  running egg_info
  writing requirements to Lib/python_ldap.egg-info/requires.txt
  writing Lib/python_ldap.egg-info/PKG-INFO
  writing top-level names to Lib/python_ldap.egg-info/top_level.txt
  writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
  warning: manifest_maker: standard file '-c' not found
  
  file Lib/ldap.py (for module ldap) not found
  file Lib/ldap/controls.py (for module ldap.controls) not found
  file Lib/ldap/extop.py (for module ldap.extop) not found
  file Lib/ldap/schema.py (for module ldap.schema) not found
  reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'Makefile'
  warning: no files found matching 'Modules/LICENSE'
  writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
  running build_ext
  building '_ldap' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/Modules
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.21 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o
  Modules/LDAPObject.c:18:18: fatal error: sasl.h: No such file or directory
   #include &lt;sasl.h&gt;
                    ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Command "/home/kmertig/hd_request/hd_request/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-V4vhsl/python-ldap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NIR67Y-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kmertig/hd_request/hd_request/include/site/python2.7/python-ldap" failed with error code 1 in /tmp/pip-build-V4vhsl/python-ldap
  </code></pre>
  
  <p>If I try to pip install any of the suggested dev libraries so that they are inside my virtual environment, I get the following error.</p>
  
  <pre><code>  Could not find a version that satisfies the requirement libsasl2-dev (from versions: ) No matching distribution found for libsasl2-dev
  </code></pre>
  
  <p>I can install all this stuff globally just fine, but that just plain defeats the purpose of using virtualenv.  </p>
  
  <p>I would really like to find a meaningful, virtualenv solution, since all I have been able to find is non-virtualenv solutions for a virtualenv question.</p>
  
  <p>Thanks.</p>