When I run the following command:
sudo pip install python-ldap
I get this error:
In file included from Modules/LDAPObject.c:9:
Modules/errors.h:8: fatal error: lber.h: No such file or directory
Any ideas how to fix this?
The python-ldap is based on OpenLDAP, so you need to have the development files (headers) in order to compile the Python module. If you're on Ubuntu, the package is called libldap2-dev.
Debian/Ubuntu:
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
RedHat/CentOS:
sudo yum install python-devel openldap-devel
To install python-ldap successfully with pip, following development libraries are needed (package names taken from ubuntu environment):
sudo apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev
On CentOS/RHEL 6, you need to install:
sudo yum install python-devel
sudo yum install openldap-devel
and yum will also install cyrus-sasl-devel as a dependency. Then you can run:
pip-2.7 install python-ldap
"Don't blindly remove/install software"
In a Ubuntu or Debian based distro, you can use apt-file to find the name of the exact package that includes the missing header file.
# do this once
sudo apt-get install apt-file
sudo apt-file update
$ apt-file search lber.h
libldap2-dev: /usr/include/lber.h
As you could see from the output of apt-file search lber.h, you'd just need to install the package libldap2-dev.
sudo apt-get install libldap2-dev
In Ubuntu it looks like this :
$ sudo apt-get install python-dev libldap2-dev libsasl2-dev libssl-dev
$ sudo pip install python-ldap
Windows: I completely agree with the accepted answer, but digging through the comments took a while to get to the meat of what I needed. I ran across this specific problem with Reviewboard on Windows using the Bitnami. To give an answer for windows then, I used this link mentioned in the comments:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
placed that wheel (whl file) into my reviewboard install directory
Then, executed the following commands
easy_install pip
pip install python_ldap-2.4.20-cp27-none_win32.whl
(because I had python 2.7 and a 32bit install at that)
easy_install python-ldap
For those having the same issue of missing Iber.h on Alpine Linux, in a docker image that you are trying to adapt to Alpine for instance.
The package you are looking for is: openldap-dev
So run
apk add openldap-dev
Available from version 3.3 up to Edge
Available for both armhf and x86_64 Architectures.
On Fedora 22, you need to do this instead:
sudo dnf install python-devel
sudo dnf install openldap-devel
On openSUSE you need to install the packages openldap2-devel, cyrus-sasl-devel, python-devel and libopenssl-devel.
zypper install openldap2-devel cyrus-sasl-devel python-devel libopenssl-devel
python3 does not support python-ldap. Rather to install ldap3.
For alpine docker
apk add openldap-dev
if the python version is 3 and above try
pip install python3-ldap
I had problems with the installation on Windows, so one of the solutions is to install the ldap package manually.
A few steps:
Go to the page pyldap or/and python-ldap and download the latest version *whl.
Open a console then cd to where you've downloaded your file like some-package.whl and use:
pip install some-package.whl
The current version for pyldap is 2.4.45. On a concrete example the installation would be:
pip install .\pyldap-2.4.45-cp37-cp37m-win_amd64.whl
# or
pip install .\python_ldap‑3.3.1‑cp39‑cp39‑win_amd64.whl
Output:
Installing collected packages: pyldap
Successfully installed pyldap-2.4.45
EDIT
You can install the proper version for Python-3.X though using following command:
# if pip3 is the default pip alias for python-3
pip3 install python3-ldap
# otherwise
pip install python3-ldap
Also here is the link of PiPy package for further information: python3-ldap 0.9.8.4
OR
ldap3 is a strictly RFC 4510 conforming LDAP V3 pure Python client library. The same codebase runs in Python 2, Python 3, PyPy and PyPy3: https://github.com/cannatag/ldap3
pip install ldap3
from ldap3 import Server, Connection, SAFE_SYNC
server = Server('my_server')
conn = Connection(server, 'my_user', 'my_password', client_strategy=SAFE_SYNC, auto_bind=True)
status, result, response, _ = conn.search('o=test', '(objectclass=*)')
# usually you don't need the original request (4th element of the returned tuple)
For most systems, the build requirements are now mentioned in python-ldap's documentation, in the "Installing" section.
If anything is missing for your system (or your system is missing entirely), please let maintainer know!
(As of 2018, I am the maintainer, so a comment here should be enough. Or you can send a pull request or mail.)
To correct the error due to dependencies to install the python-ldap : Windows 7/10
download the whl file
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap.
python 3.6 suit with
python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
Deploy the file in :
c:\python36\Scripts\
install it with
python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
sudo apt-get install build-essential python3-dev python2.7-dev libldap2-dev libsasl2-dev slapd ldap-utils python-tox lcov valgrind
Debian Reference :
https://www.python-ldap.org/en/latest/installing.html#debian
For others: https://www.python-ldap.org/en/latest/installing.html
On OSX, you need the xcode CLI tools. Just open a terminal and run:
xcode-select --install
For ArchLinux/Manjaro for me helped the following command:
yay libldap24
As of december 2021 there was/is a strange problem with the ldap library (at least in arch/manjaro).
While installing python-ldap (at 'Building wheel for python-ldap') I got the message 'ERROR: Failed building wheel for python-ldap':
/usr/bin/ld: cannot find -lldap_r
collect2: error: ld returned 1 exit status
error: command '/usr/bin/gcc' failed with exit code 1
a workaround is provided here: https://github.com/python-ldap/python-ldap/issues/432#issuecomment-974799221
I cite:
As a workaround create the file /usr/lib64/libldap_r.so with content
INPUT ( libldap.so ). The approach works on all systems that use a GNU
ld-compatible linker.
# cat > /usr/lib64/libldap_r.so << EOF
INPUT ( libldap.so )
EOF
In FreeBSD 11:
pkg install openldap-client # for lber.h
pkg install cyrus-sasl # if you need sasl.h
pip install python-ldap
As a general solution to install Python packages with binary dependencies [1] on Debian/Ubuntu:
sudo apt-get build-dep python-ldap
# installs system dependencies (but not the package itself)
pew workon my_virtualenv # enter your virtualenv
pip install python-ldap
You'll have to check the name of your Python package on Ubuntu versus PyPI. In this case they're the same.
Obviously doesn't work if the Python package is not in the Ubuntu repos.
[1] I learnt this trick when trying to pip install matplotlib on Ubuntu.
If you're working with windows machines, you can find 'python-ldap' wheel in this Link and then you can install it
for those who are using alphine linux,
apk add openldap-dev
try:
ARCHFLAGS="-arch x86_64" pip3 install python-ldap
Adding also libzbar-dev solved for me the installation of python-ldap when building DOCKER
The full command becomes:
apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev libzbar-dev
A hack answer for FreeBSD 13.1 (yes, I know this is deep South of best practices, but I just needed a quick fix):
pkg install openldap24-client
cd /usr/local/include/python3.9
ln -s ../<all of the below> .
lber.h
lber_types.h
ldap.h
ldap_cdefs.h
ldap_features.h
ldap_schema.h
ldap_utf8.h
openldap.h
sasl
pip install python-ldap
Related
I get this error when running
$ pip3 install -U pip
Requirement already up-to-date: pip in ./dlenv/lib/python3.6/site-packages (10.0.1)
launchpadlib 1.10.6 requires testresources, which is not installed.
I have searched in apt and testresources seems to be installed already.
apt search testresources
Sorting... Done
Full Text Search... Done
python-testresources/bionic,bionic 2.0.0-2 all
PyUnit extension for managing expensive test fixtures - Python 2.x
python3-testresources/bionic,bionic 2.0.0-2 all
PyUnit extension for managing expensive test fixtures - Python 3.
I've gone through this github issue, which was not clear with a solution.
try this,
sudo apt install python3-testresources
Suggest installing pip by the PyPA guide on Ubuntu 18.04, since the pip version is too old if we install it by sudo apt install python3-pip.
Following work for me:
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# python get-pip.py
BTW, the default location of pip is /usr/local/bin/pip, in case can't find the PATH.
Try this
sudo apt-get remove python-pip python-dev - This will remove the pip and python
then install the required version of python and pip
I have built python from scratch and it now sits in a folder in my home directory. I am unsure of how to install libraries for this particular version/location.
Ubuntu comes with 2.7.6 and I need something in particular from 2.7.11.
Thanks!
First of all get setuptools
apt-get update
apt-get install python-setuptools
apt-get install python-pip
If you plan to use git and other tools install
apt-get install git
apt-get install python-dev
Once pip and setuptools are in place you can get any modules with either pip
or easy_install
Get setuptools from https://pypi.python.org/pypi/setuptools
run
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
now you got setuptools and ez_setup.py - locate this file and run
python ez_setup.py
Now you have easy_install, so you can either use it or install pip:
easy_install pip
At that point you should be able to use pip.
Just started Python a few days ago and I'm using PyCharm to develop a web application with Django. I have libpq-dev python-dev packages already installed, but it's still throwing me the same error:
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
which according to Google is the issue that occurs when python-dev package isn't installed. Note that I'm running the install from within the PyCharm interface for a virtualenv that I created for 3.2 and 3.3 (not sure how to run it from the terminal). Installing outside of the virtualenv still throws the same error, even when I install it from the terminal with setup.py. If I run pip install psycopg2 from the terminal, it succeeds, but it installs for Python 2.7. According to their website, they have support for up to Python 3.2.
On Ubuntu you just run this:
sudo apt-get install python3-psycopg2
Just run this using the terminal:
$ sudo apt-get install python3-dev
This way, you could use gcc to build the module you're trying to use.
Another option that seems to provide a newer version of psycopg2 than the one in the python3-psycopg2 package (at least when I wrote this):
sudo apt-get install pip3
sudo apt-get install libpq-dev
sudo pip3 install psycopg2
For most operating systems, the quickest way to install Psycopg is using the wheel package available on PyPI:
$ pip install psycopg2-binary
Check:
$ pip freeze | grep -i psycopg2
psycopg2-binary==2.9.3
This will install a pre-compiled binary version of the module which does not require the build or runtime prerequisites.
Or:
$ sudo apt-get install libpq-dev
$ pip install psycopg2
Check:
$ pip freeze | grep -i psycopg2
psycopg2==2.9.3
More info about psycopg vs psycopg-binary.
Hello when I attempt to install pylibmc on OSX Lion using pip I get the following error:
./_pylibmcmodule.h:42:10: fatal error: 'libmemcached/memcached.h' file not found
#include <libmemcached/memcached.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
Any clues at how to solve this issue?
libmemcached may also be installed using Homebrew.
brew install libmemcached
After that, pip install pylibmc worked for me without needing to specify any additional arguments.
It's in the libmemcached package. To install it using macports:
sudo port install libmemcached
Then, assuming you're using pip:
pip install pylibmc --install-option="--with-libmemcached=/opt/local"
or
LIBMEMCACHED=/opt/local pip install pylibmc
as explained in the pylibmc docs.
I solved this issue by checking where memcached is installed
$ which memcached
/usr/local/bin/memcached
and then setting LIBMEMCACHED environment variable before pip install:
$ export LIBMEMCACHED=/usr/local
$ pip install pylibmc
Answer for Ubuntu users:
sudo apt install libmemcached-dev zlib1g-dev
I have the same problem because i have installed MEMCACHED and not LIBMEMCACHED, so, to resolve:
brew uninstall memcached #to remove wrong package
brew install libmemcached #install correct lib
pip install pylibmc
Its Works for me!
: )
For those finding this answer on Fedora:
sudo yum install libmemcached-devel
Hit the same error with macOS High Sierra, Python3.6 installed with brew. Solution for me was to export these flags, mentioned in this comment: Error when install pylibmc using pip
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"
After that, pip install run just fine.
i fixed this by installing memcached from port
you should install first macports from http://www.macports.org/
then run this command
sudo port install memcached
after that download the pylibmc from the pypi http://pypi.python.org/pypi/pylibmc
extract .tar.gz file then
python setup.py install --with-libmemcached=/opt/local
this code is worked for me
sudo apt-get install libmemcached-dev zlib1g-dev
LIBMEMCACHED=/opt/local pip install pylibmc
Sometimes the X-Code Command Line Tools need to be installed.
xcode-select -p
I wanted to install eventlet on my system in order to have "Herd" for software deployment.. but the terminal is showing a gcc error:
root#agrover-OptiPlex-780:~# easy_install -U eventlet
Searching for eventlet
Reading http://pypi.python.org/simple/eventlet/
Reading http://wiki.secondlife.com/wiki/Eventlet
Reading http://eventlet.net
Best match: eventlet 0.9.16
Processing eventlet-0.9.16-py2.7.egg
eventlet 0.9.16 is already the active version in easy-install.pth
Using /usr/local/lib/python2.7/dist-packages/eventlet-0.9.16-py2.7.egg
Processing dependencies for eventlet
Searching for greenlet>=0.3
Reading http://pypi.python.org/simple/greenlet/
Reading https://github.com/python-greenlet/greenlet
Reading http://bitbucket.org/ambroff/greenlet
Best match: greenlet 0.3.4
Downloading http://pypi.python.org/packages/source/g/greenlet/greenlet- 0.3.4.zip#md5=530a69acebbb0d66eb5abd83523d8272
Processing greenlet-0.3.4.zip
Writing /tmp/easy_install-_aeHYm/greenlet-0.3.4/setup.cfg
Running greenlet-0.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_aeHYm/greenlet-0.3.4/egg-dist-tmp-t9_gbW
In file included from greenlet.c:5:0:
greenlet.h:8:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1`
Why can't Python.h be found?
Your install is failing because you don't have the python development headers installed. You can do this through apt on ubuntu/debian with:
sudo apt-get install python-dev
for python3 use:
sudo apt-get install python3-dev
For eventlet you might also need the libevent libraries installed so if you get an error talking about that you can install libevent with:
sudo apt-get install libevent-dev
For Fedora:
sudo yum install python-devel
sudo yum install libevent-devel
and finally:
sudo easy_install gevent
What worked for me on CentOS was:
sudo yum -y install gcc
sudo yum install python-devel
For Redhat Versions(Centos 7) Use the below command to install Python Development Package
Python 2.7
sudo yum install python-dev
Python 3.4
sudo yum install python34-devel
Python 3.6
sudo yum install python36-devel
If the issue is still not resolved then try installing the below packages -
sudo yum install python-devel
sudo yum install openssl-devel
sudo yum install libffi-devel
On MacOS I had trouble installing fbprophet which requires pystan which requires gcc to compile. I would consistently get the same error: command 'gcc' failed with exit status 1
I think I fixed the problem for myself thus:
I used brew install gcc to install the newest version, which ended up being gcc-8
Then I made sure that when gcc ran it would use gcc-8 instead.
It either worked because I added alias gcc='gcc-8 in my .zshrc (same as .bashrc but for zsh), or because I ran export PATH=/usr/local/bin:$PATH (see comment)
Also: all my attempts were inside a virtual environment and I only succeeded by installing fbprophet globally (with pip), but still no success inside a venv
This is an old post but I just run to the same problem on AWS EC2 installing regex. This working perfectly for me
sudo yum -y install gcc
and next
sudo yum -y install gcc-c++
If it is still not working, you can try this
sudo apt-get install build-essential
in my case, it solved the problem.
try this :
sudo apt-get install libblas-dev libatlas-base-dev
I had a similar issue on Ubuntu 14.04. For me the following Ubuntu packages
On MacOS I also had problems trying to install fbprophet which had gcc as one of its dependencies.
After trying several steps as recommended by #Boris the command below from the Facebook Prophet project page worked for me in the end.
conda install -c conda-forge fbprophet
It installed all the needed dependencies for fbprophet. Make sure you have anaconda installed.
This page is gonna save your life, for all further lib issues that are forthcoming,
For Alpine(>=3.6), use
apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev
For CentOS 7.2:
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511
Codename: Core
Install eventlet:
sudo yum install python-devel
sudo easy_install -ZU eventlet
Terminal info:
[root#localhost ~]# easy_install -ZU eventlet
Searching for eventlet
Reading http://pypi.python.org/simple/eventlet/
Best match: eventlet 0.19.0
Downloading https://pypi.python.org/packages/5a/e8/ac80f330a80c18113df0f4f872fb741974ad2179f8c2a5e3e45f40214cef/eventlet-0.19.0.tar.gz#md5=fde857181347d5b7b921541367a99204
Processing eventlet-0.19.0.tar.gz
Running eventlet-0.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Hh9GQY/eventlet-0.19.0/egg-dist-tmp-rBFoAx
Adding eventlet 0.19.0 to easy-install.pth file
Installed /usr/lib/python2.6/site-packages/eventlet-0.19.0-py2.6.egg
Processing dependencies for eventlet
Finished processing dependencies for eventlet
For openSUSE 42.1 Leap Linux use this
sudo zypper install python3-devel
I am using MacOS catalina 10.15.4. None of the posted solutions worked for me. What worked for me is:
>> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
>> env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2==2.8.4
Collecting psycopg2==2.8.4
Using cached psycopg2-2.8.4.tar.gz (377 kB)
Installing collected packages: psycopg2
Attempting uninstall: psycopg2
Found existing installation: psycopg2 2.7.7
Uninstalling psycopg2-2.7.7:
Successfully uninstalled psycopg2-2.7.7
Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.4
use pip3 for python3
if you are on Mac as myself, try this in your terminal: xcode-select --install
Then accept the installation request, and it works afterwards as described in this issue
Build from source and install, this is fixed in the latest release (10.3+):
mkdir -p /tmp/install/netifaces/
cd /tmp/install/netifaces && wget -O "netifaces-0.10.4.tar.gz" "https://pypi.python.org/packages/source/n/netifaces/netifaces-0.10.4.tar.gz#md5=36da76e2cfadd24cc7510c2c0012eb1e"
tar xvzf netifaces-0.10.4.tar.gz
cd netifaces-0.10.4 && python setup.py install
Similarly I fixed it like this (notice python34):
sudo yum install python34-devel
sudo apt install gcc
It works for PyCharm on Ubuntu 20.10.
If you are migrating to a more modern version of python3 e.g. python3.5 to python3.8 You may want to check/upgrade the versions of the library that are failing if you have already installed the recommended libraries to handle gcc building python3-dev + other libraries as suggested.
It depends on the package. Some versions of the packages may not be supported on later versions of python3.