Discussion:
[python-ldap] problems using import ldap
Francis Abrante
2011-07-18 08:22:45 UTC
Permalink
Hi

I already install the openldap and the python-ldap but I can't use the library, I don't know where is or how to add it in my pycharm. I am working locally and I have ubuntu, also I did the python-ldap installation with apt-get (but I don't know where are the files)

Thanks in advance

Francis
Michael Ströder
2011-07-18 18:31:17 UTC
Permalink
Post by Francis Abrante
I already install the openldap and the python-ldap but I can't use the
library, I don't know where is or how to add it in my pycharm. I am
working locally and I have ubuntu, also I did the python-ldap installation
with apt-get (but I don't know where are the files)
What does

python -c "import ldap;print ldap.__version__"

say?

Ciao, Michael.
Michael Ströder
2011-07-19 08:42:20 UTC
Permalink
Francis,

please always follow-up on the mailing list (cc:-ed).

Unfortunately you also do not provide any information needed to help you.
this is the output
Thanks
File "<string>", line 1, in <module>
ImportError: No module named ldap
So how did you install python-ldap? If you're using a pre-packaged version of
python-ldap found in Ubuntu the command above should simply work - provided
you're using the right Python interpreter.

If you decide to build and install python-ldap yourself then you should follow
the instructions here:

http://www.python-ldap.org/doc/html/installing.html

Ciao, Michael.
Michael Wood
2011-07-19 08:53:02 UTC
Permalink
Hi
Post by Michael Ströder
Francis,
please always follow-up on the mailing list (cc:-ed).
Unfortunately you also do not provide any information needed to help you.
this is the output
Thanks
  File "<string>", line 1, in <module>
ImportError: No module named ldap
So how did you install python-ldap? If you're using a pre-packaged version of
python-ldap found in Ubuntu the command above should simply work - provided
you're using the right Python interpreter.
In his initial post he said:

"I did the python-ldap installation with apt-get"

so I agree that should "just work".
Post by Michael Ströder
If you decide to build and install python-ldap yourself then you should follow
http://www.python-ldap.org/doc/html/installing.html
I think it would be better to get the version installed via apt-get to
work than to install it manually.

Francis, what do the following commands give you?

$ dpkg -l python-ldap
$ dpkg -l 'python[23]*' | grep ^i
$ which python
$ ls -l $(which python)
$ ls -l /usr/bin/python
$ lsb_release -a
--
Michael Wood <***@gmail.com>
Michael Ströder
2011-07-19 08:56:01 UTC
Permalink
And if anyone is curious *where* Python modules get installed by DistUtils:

http://docs.python.org/install/index.html#how-installation-works

Ciao, Michael.
Francis Abrante
2011-07-19 11:34:16 UTC
Permalink
Hi

I executed the commands:

***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ dpkg -l python-ldap
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  python-ldap    2.3.10-1ubuntu LDAP interface module for Python


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ dpkg -l 'python[23]*' | grep ^i
ii  python2.6                            2.6.5-1ubuntu6                                  An interactive high-level object-oriented la
ii  python2.6-dbg                        2.6.5-1ubuntu6                                  Debug Build of the Python Interpreter (versi
ii  python2.6-minimal                    2.6.5-1ubuntu6                                  A minimal subset of the Python language (ver


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ which python
/usr/local/bin/python


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ ls -l $(which python)
-rwxr-xr-x 2 root root 4362121 2011-07-04 16:43 /usr/local/bin/python


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 2011-05-25 11:04 /usr/bin/python -> python2.6


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 10.04.2 LTS
Release:    10.04
Codename:    lucid


Thanks for your help

--- El mar, 7/19/11, Michael Wood <***@gmail.com> escribió:

De: Michael Wood <***@gmail.com>
Asunto: Re: [python-ldap] problems using import ldap
A: "Michael Ströder" <***@stroeder.com>
Cc: "Francis Abrante" <***@yahoo.com>, python-***@python.org
Fecha: martes, 19 de julio de 2011, 05:53 am

Hi
Post by Michael Ströder
Francis,
please always follow-up on the mailing list (cc:-ed).
Unfortunately you also do not provide any information needed to help you.
this is the output
Thanks
  File "<string>", line 1, in <module>
ImportError: No module named ldap
So how did you install python-ldap? If you're using a pre-packaged version of
python-ldap found in Ubuntu the command above should simply work - provided
you're using the right Python interpreter.
In his initial post he said:

"I did the python-ldap installation with apt-get"

so I agree that should "just work".
Post by Michael Ströder
If you decide to build and install python-ldap yourself then you should follow
http://www.python-ldap.org/doc/html/installing.html
I think it would be better to get the version installed via apt-get to
work than to install it manually.

Francis, what do the following commands give you?

$ dpkg -l python-ldap
$ dpkg -l 'python[23]*' | grep ^i
$ which python
$ ls -l $(which python)
$ ls -l /usr/bin/python
$ lsb_release -a
--
Michael Wood <***@gmail.com>
Michael Wood
2011-07-19 11:55:43 UTC
Permalink
Post by Francis Abrante
Hi
OK, so it looks like you might have been trying to install python-ldap
2.4 manually as well. It might confuse the issue if you have two
different versions installed.
Post by Francis Abrante
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  python-ldap    2.3.10-1ubuntu LDAP interface module for Python
OK, so python-ldap 2.3.10 is installed via apt-get.
Post by Francis Abrante
ii  python2.6                            2.6.5-1ubuntu6                                  An interactive high-level object-oriented la
and you have Python 2.6 installed via apt-get too (well, it came pre-installed).
Post by Francis Abrante
ii  python2.6-dbg                        2.6.5-1ubuntu6                                  Debug Build of the Python Interpreter (versi
ii  python2.6-minimal                    2.6.5-1ubuntu6                                  A minimal subset of the Python language (ver
/usr/local/bin/python
Aha! So you have another installation of Python on your system and
it's not the one that runs when you type:

$ python

I suspect this has something to do with "pycharm" which you mentioned
in your first message. I am not familiar with pycharm, though. If
this rogue installation of python is because of pycharm, you might
want to ask the pycharm developers about your problem with getting
python-ldap to work.

What does this say:

$ /usr/bin/python -c "import ldap;print ldap.__version__"

Also:

$ python --version
Post by Francis Abrante
-rwxr-xr-x 2 root root 4362121 2011-07-04 16:43 /usr/local/bin/python
lrwxrwxrwx 1 root root 9 2011-05-25 11:04 /usr/bin/python -> python2.6
OK, so the "proper" installation of python is version 2.6 and it
hasn't been symlinked to somewhere else.
Post by Francis Abrante
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 10.04.2 LTS
Release:    10.04
Codename:    lucid
Thanks for your help
No problem. But I think the pycharm developers/mailing
list/forum/whatever might be a better place to ask your question.
--
Michael Wood <***@gmail.com>
Michael Wood
2011-07-19 11:58:21 UTC
Permalink
[...]
Post by Francis Abrante
/usr/local/bin/python
Aha!  So you have another installation of Python on your system and
$ python
I mean that it *is* the one that runs when you type "python".

This is why the command Michael Stroeder asked you to type did not work.
--
Michael Wood <***@gmail.com>
Francis Abrante
2011-07-19 12:07:09 UTC
Permalink
Hi again

I tried to uninstall and install the package and doesn't work either.

***@orbac-desktop:~/python-ldap/python-ldap-2.4.0# apt-get install python-ldap
Reading package lists... Done
Building dependency tree      
Reading state information... Done
python-ldap is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0# apt-get remove python-ldap
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages will be REMOVED:
  python-ldap
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
After this operation, 352kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 150730 files and directories currently installed.)
Removing python-ldap ...


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0# apt-get install python-ldapReading package lists... Done
Building dependency tree      
Reading state information... Done
Suggested packages:
  python-ldap-doc
The following NEW packages will be installed:
  python-ldap
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 0B/75.2kB of archives.
After this operation, 352kB of additional disk space will be used.
Selecting previously deselected package python-ldap.
(Reading database ... 150683 files and directories currently installed.)
Unpacking python-ldap (from .../python-ldap_2.3.10-1ubuntu1_i386.deb) ...
Setting up python-ldap (2.3.10-1ubuntu1) ...
Processing triggers for python-central ...


***@orbac-desktop:~/python-ldap/python-ldap-2.4.0# python -c "import ldap;print ldap.__version__"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named ldap


--- El mar, 7/19/11, Michael Wood <***@gmail.com> escribió:

De: Michael Wood <***@gmail.com>
Asunto: Re: [python-ldap] problems using import ldap
A: "Michael Ströder" <***@stroeder.com>
Cc: "Francis Abrante" <***@yahoo.com>, python-***@python.org
Fecha: martes, 19 de julio de 2011, 05:53 am

Hi
Post by Michael Ströder
Francis,
please always follow-up on the mailing list (cc:-ed).
Unfortunately you also do not provide any information needed to help you.
this is the output
Thanks
  File "<string>", line 1, in <module>
ImportError: No module named ldap
So how did you install python-ldap? If you're using a pre-packaged version of
python-ldap found in Ubuntu the command above should simply work - provided
you're using the right Python interpreter.
In his initial post he said:

"I did the python-ldap installation with apt-get"

so I agree that should "just work".
Post by Michael Ströder
If you decide to build and install python-ldap yourself then you should follow
http://www.python-ldap.org/doc/html/installing.html
I think it would be better to get the version installed via apt-get to
work than to install it manually.

Francis, what do the following commands give you?

$ dpkg -l python-ldap
$ dpkg -l 'python[23]*' | grep ^i
$ which python
$ ls -l $(which python)
$ ls -l /usr/bin/python
$ lsb_release -a
--
Michael Wood <***@gmail.com>
Michael Ströder
2011-07-19 12:16:34 UTC
Permalink
Post by Michael Ströder
ldap;print ldap.__version__"
File "<string>", line 1, in <module>
ImportError: No module named ldap
Please read the Python docs at the link I've already posted:

http://www.python-ldap.org/doc/html/installing.html

Especially find out which Python interpreter you're environment is really
using. Then type

§ /path/to/python -c "import sys;print sys.prefix;print sys.exec_prefix"
/usr
/usr

where /path/to is the full path to the Python interpreter executable you're
trying to use. See the docs above how that helps to find out where modules get
installed.

Similar when building/installing from source

/path/to/python setup.py install

has to be invoked to install python-ldap (like all other DistUtils-based
Python modules).

Ciao, Michael.
Michael Wood
2011-07-19 12:35:16 UTC
Permalink
Post by Francis Abrante
Hi again
I tried to uninstall and install the package and doesn't work either.
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-ldap is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
That's because it is already correctly installed. The problem is not
with the python-ldap package, but rather with your non-standard
installation of Python (/usr/local/bin/python), which as I said I
suspect has something to do with "pycharm", with which I am
unfamiliar.

[...]
Post by Francis Abrante
  File "<string>", line 1, in <module>
ImportError: No module named ldap
You did not correctly follow my instructions.

I said you should try:

$ /usr/bin/python -c "import ldap;print ldap.__version__"

and not just:

$ python -c "import ldap;print ldap.__version__"

And I still think pycharm is what's causing this to not just work out
of the box. So you might want to contact them rather.
--
Michael Wood <***@gmail.com>
Francis Abrante
2011-07-28 08:25:02 UTC
Permalink
Hi

I still have problems, but I think that my problem come from the library version. I don't know from where I can get the egg version for python 2.7. From    http://svn.kmrc.de/download/distribution/contrib/  only allow me until 2.6 


/usr/local/bin/python2.7 /home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP Agent/get_info.py
Traceback (most recent call last):
  File "/home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP Agent/get_info.py", line 1, in <module>
    import ldap
  File "/usr/local/lib/python2.7/site-packages/python_ldap-2.3.9-py2.6-linux-x86_64.egg/ldap/__init__.py", line 22, in <module>
    from _ldap import *
ImportError: /usr/local/lib/python2.7/site-packages/python_ldap-2.3.9-py2.6-linux-x86_64.egg/_ldap.so: wrong ELF class: ELFCLASS64

Process finished with exit code 1



By the way:

***@orbac-desktop:~/python-ldap$ /usr/bin/python -c "import ldap;print ldap.__version__"
2.3.10


Thanks.

________________________________
De: Michael Wood <***@gmail.com>
Para: Francis Abrante <***@yahoo.com>
CC: Michael Ströder <***@stroeder.com>; python-***@python.org
Enviado: Martes, julio 19, 2011 2:35 P.M.
Asunto: Re: [python-ldap] problems using import ldap
Post by Francis Abrante
Hi again
I tried to uninstall and install the package and doesn't work either.
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-ldap is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
That's because it is already correctly installed.  The problem is not
with the python-ldap package, but rather with your non-standard
installation of Python (/usr/local/bin/python), which as I said I
suspect has something to do with "pycharm", with which I am
unfamiliar.

[...]
Post by Francis Abrante
  File "<string>", line 1, in <module>
ImportError: No module named ldap
You did not correctly follow my instructions.

I said you should try:

$ /usr/bin/python -c "import ldap;print ldap.__version__"

and not just:

$ python -c "import ldap;print ldap.__version__"

And I still think pycharm is what's causing this to not just work out
of the box.  So you might want to contact them rather.
--
Michael Wood <***@gmail.com>
Francis Abrante
2011-07-28 08:36:35 UTC
Permalink
Hi


I think that this is the version that I need, but I cannot found it.


python_ldap-2.4.0-py2.7-linux-x86_64.egg



________________________________
De: Francis Abrante <***@yahoo.com>
Para: Michael Wood <***@gmail.com>
CC: Michael Ströder <***@stroeder.com>; "python-***@python.org" <python-***@python.org>
Enviado: Jueves, julio 28, 2011 10:25 A.M.
Asunto: Re: [python-ldap] problems using import ldap


Hi

I still have problems, but I think that my problem come from the library version. I don't know from where I can get the egg version for python 2.7. From    http://svn.kmrc.de/download/distribution/contrib/  only allow me until 2.6 


/usr/local/bin/python2.7 /home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP Agent/get_info.py
Traceback (most recent call last):
  File "/home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP Agent/get_info.py", line 1, in <module>
    import ldap
  File "/usr/local/lib/python2.7/site-packages/python_ldap-2.3.9-py2.6-linux-x86_64.egg/ldap/__init__.py", line 22, in
<module>
    from _ldap import *
ImportError: /usr/local/lib/python2.7/site-packages/python_ldap-2.3.9-py2.6-linux-x86_64.egg/_ldap.so: wrong ELF class: ELFCLASS64

Process finished with exit code 1



By the way:

***@orbac-desktop:~/python-ldap$ /usr/bin/python -c "import ldap;print ldap.__version__"
2.3.10

Thanks.

________________________________
De: Michael Wood <***@gmail.com>
Para: Francis Abrante <***@yahoo.com>
CC: Michael Ströder <***@stroeder.com>; python-***@python.org
Enviado: Martes, julio 19, 2011 2:35 P.M.
Asunto: Re: [python-ldap] problems using import ldap
Post by Francis Abrante
Hi again
I tried to uninstall and install the package and doesn't work either.
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-ldap is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
That's because it is already correctly
installed.  The problem is not
with the python-ldap package, but rather with your non-standard
installation of Python (/usr/local/bin/python), which as I said I
suspect has something to do with "pycharm", with which I am
unfamiliar.

[...]
Post by Francis Abrante
  File "<string>", line 1, in <module>
ImportError: No module named ldap
You did not correctly follow my instructions.

I said you should try:

$ /usr/bin/python -c "import ldap;print ldap.__version__"

and not just:

$ python -c "import ldap;print ldap.__version__"

And I still think pycharm is what's causing this to not just work out
of the box.  So you might want to contact them rather.
--
Michael Wood <***@gmail.com>
Michael Ströder
2011-07-28 08:39:44 UTC
Permalink
Post by Francis Abrante
I still have problems, but I think that my problem come from the library
version. I don't know from where I can get the egg version for python 2.7.
Francis Abrante
2011-07-28 11:24:23 UTC
Permalink
Hi

I already uninstall the other versions, but where can I get the library for 32 bits?


python_ldap-2.4.0-py2.7

Thanks



________________________________
De: Michael Ströder <***@stroeder.com>
Para: Francis Abrante <***@yahoo.com>
CC: "python-***@python.org" <python-***@python.org>
Enviado: Jueves, julio 28, 2011 10:39 A.M.
Asunto: Re: [python-ldap] problems using import ldap
Post by Francis Abrante
I still have problems, but I think that my problem come from the library
version. I don't know from where I can get the egg version for python 2.7.
From    http://svn.kmrc.de/download/distribution/contrib/  only allow me until
2.6
/usr/local/bin/python2.7
/home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP Agent/get_info.py
  File "/home/orbac/TSP-CloudStack/src/it/tsp/cloudstack/orbac/LDAP
Agent/get_info.py", line 1, in <module>
    import ldap
  File
"/usr/local/lib/python2.7/site-packages/python_ldap-2.3.9-py2.6-linux-x86_64.egg/ldap/__init__.py",
line 22, in <module>
    from _ldap import *
wrong ELF class: ELFCLASS64
This rather sounds to me that you've compiled python-ldap for 64-bit platform
but the Python interpreter you're using is a 32-bit build.

It seems that to that you should really clean up your system. You're mixing
build platforms, Python versions, python-ldap etc. That's a big mess.

Especially you should read and understand about how DistUtils are working (the
link I've posted before).

Ciao, Michael.
Michael Ströder
2011-07-28 11:31:08 UTC
Permalink
Post by Francis Abrante
I already uninstall the other versions, but where can I get the library for 32 bits?
python_ldap-2.4.0-py2.7
Simply build and install python-ldap with the *very same* Python interpreter
you're planning to use it with. (As you have been told in this thread several
times...)

Ciao, Michael.

Loading...