9

I am using Windows as my main python 2.7 development environment and I want to install python-ldap on a virtual environment.

The python-ldap package needs compiling :( and of course I can't compile it in my environment. So I tried finding binaries in order to install them in my virtual environment through easy_install (FYI you can do easy_install package.exe and the package will be installed). I found the distributed binaries here: https://pypi.python.org/pypi/python-ldap/

Unfortunately, they give only .msi packages for python 2.7 !!! Why do people use .msi ? MSI CANNOT BE INSTALLED THROUGH easy_install. I HATE MSI %$#$^#$^#$

Yes I can install the .msi package by executing it but it will be installed in the global python packages and not on my virtual environment!

Please, can anybody help me ? I remember having this exact problem in a previous project and I had to develop it outside of a virtual environment -- but I cannot do this now :(

Update: I installed python-ldap system-wide and copied the directories ldap and python_ldap-2.4.10-py2.7.egg-info from PYTHON_GLOBAL\Lib\site-packages to VIRTUALENV\Lib\site-packages and seems to be working now. However I really don't like that solution so I won't answer my question with that. Also, Alexander's comment on recreating my virtualenv with --system-site-packages probably will be working but this means that I'd need to uninstall a lot of my global packages packages and then install again my virtual packages etc and in general it's not DRY :(

Update 2: After trying cgohlke's suggestion, I saw that the contents of the MSI were the two directories I mentioned above along with the files dsml.py, ldapurl.py and ldif.py. So I also copied this to my VIRTUALENV\Lib\site-packages. Now I believe that the installation is ok :). But I believe that cgohlke's is the best one - just use msiexec.exe to extract the contents of the msi directly to your VIRTUALENV.

Update 3: In a similar question (Installing python-ldap in a virtualenv on Windows) I found a really interesting link: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap. In there you will be able to find .EXE install packages for python-ldap and LOTS of others!!! So finally by downloading these you'll be able to easy_install them in your virtualenv!

Community
  • 1
  • 1
Serafeim
  • 14,962
  • 14
  • 91
  • 133
  • 1
    One way is to install it system-wide and recreate your virtualenv using '--system-site-packages'. – alecxe Apr 10 '13 at 06:35
  • Yes probably that will work - but I don't want to recreate my virtualenv. – Serafeim Apr 10 '13 at 06:38
  • 2
    Try to extract the msi: `msiexec.exe /a python-ldap-2.4.10.win32-py2.7.msi /qn TARGETDIR="C:\Absolute\Path"`. – cgohlke Apr 10 '13 at 06:50
  • @cgohlke I think you solution is the best - could you answer it properly so I can accept it ? Thanks ! – Serafeim Apr 10 '13 at 07:03
  • @Serafeim I am trying to install the python-ldap exe file using easy_install but when installed using this method the directory that is created is python_ldap-2.4.15-py2.7-win-amd64.egg while just runnig the exe creates two directories python_ldap-2.4.15-py2.7.egg-info and ldap. Why the difference? – Cas Apr 24 '14 at 19:52
  • 1
    Hi @Cas, I am really not sure why the difference. Both the egg-info *and* ldap are needed. In any case, as I said in my **Update 3** you should just download the ``python‑ldap‑2.4.15.win‑amd64‑py2.7.exe`` from http://www.lfd.uci.edu/~gohlke/pythonlibs and then just do an ``easy_install python‑ldap‑2.4.15.win‑amd64‑py2.7.exe`` to install it. – Serafeim Apr 24 '14 at 21:08
  • thanks for your answer @Serafeim, hmm that is precisely what I am doing, but it is not installing correctly :S – Cas Apr 24 '14 at 22:07
  • @Cas maybe you should ask another question where you describe your problem in more detail. Please state there that you've tried the answers of *this* question without luck so that your new question won't be marked as duplicate. – Serafeim Apr 25 '14 at 05:46

1 Answers1

1

How about installing it system-wide, creating an egg from installed files and then using that egg in your virtual env? You can find some info about egg structure here: http://pythonhosted.org/setuptools/formats.html

Ivan Anishchuk
  • 487
  • 3
  • 16