error: command 'gcc' failed with exit status 1 while installing eventlet - python

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.

Related

"sql.h: No such file or directory" error trying to install pyodbc on raspberry pi [duplicate]

I am running Linux (2.6.18-164.15.1.el5.centos.plus) and trying to install pyodbc. I am doing pip install pyodbc and get a very long list of errors, which end in
error: command 'gcc' failed with exit status 1
I looked in /root/.pip/pip.log and saw the following:
InstallationError: Command /usr/local/bin/python -c "import setuptools; file='/home/build/pyodbc/setup.py'; execfile('/home/build/pyodbc/setup.py')" install --single-version-externally-managed --record /tmp/pip-7MS9Vu-record/install-record.txt failed with error code 1
Has anybody had a similar issue installing pyodbc?
On Ubuntu, you'll need to install unixodbc-dev:
sudo apt-get install unixodbc-dev
Install pip by using this command:
sudo apt-get install python-pip
once that is installed, you should be able to install pyodbc successfully:
pip install pyodbc
I resolved my issue by following correct directions on pyodbc - Building wiki which states:
On Linux, pyodbc is typically built using the unixODBC headers, so you will need unixODBC and its headers installed. On a RedHat/CentOS/Fedora box, this means you would need to install unixODBC-devel:
yum install unixODBC-devel
Adding one more answer on this question.
For Linux Debian Stretch release you would need to install the following dependencies:
apt-get update
apt-get install unixodbc-dev
pip install pyodbc
On Debian Slim some users mentioned they needed to add g++
apt-get update
apt-get install g++ unixodbc-dev
pip install pyodbc
Struggled with the same issue
After running:
sudo apt-get install unixodbc-dev
I was able to pip install pyodbc
Follow below steps to install pyodbc in any redhat version
yum install unixODBC unixODBC-devel
yum install gcc-c++
yum install python-devel
pip install pyodbc
I have referenced this question several times, and gone on to actually find the answer I was looking for here:
pyodbc wiki
To avoid gcc error on Ubuntu Linux, I did:
sudo aptitude install g++
I also installed the following 2 packages from Synaptic:
python-dev
tdsodbc
Execute the following commands (tested on centos 6.5):
yum install install unixodbc-dev
yum install gcc-c++
yum install python-devel
pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
According to official Microsoft docs for Ubuntu 18.04 you should run next commands:
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
exit
If you are using python3.7, it is very important to run:
sudo apt-get install python3.7-dev
A easy way to install pyodbc is by using 'conda'. As conda automatically installs required dependencies including unixodbc.
conda --ugrade all (optional)
then
conda install pyodbc
it will install following packages:
libgfortran-ng: 7.2.0-hdf63c60_3 defaults
mkl: 2018.0.3-1 defaults
mkl_fft: 1.0.2-py36_0 conda-forge
mkl_random: 1.0.1-py36_0 conda-forge
numpy-base: 1.14.5-py36hdbf6ddf_0 defaults
pyodbc: 4.0.17-py36_0 conda-forge
unixodbc: 2.3.4-1 conda-forge
I had the same problem on CentOS 5.5
In addition to installing unixODBC-devel I also had to install gcc-c++
yum install gcc-c++
In my case (Amazon Linux AMI) none of the above worked. The following worked (idea from here):
Find the path to the file cc1plus. For me it was in /usr/libexec/gcc/x86_64-amazon-linux/4.8.5/cc1plus. For you it may vary a bit. Try ls -l /usr/libexec/gcc to find the proper directory name and go ahead.
Find directories in your path: echo $PATH (for me it was /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin)
Put a link to cc1plus in one of the directories in your PATH: sudo ln -s /PATH/TO/cc1plus /DIRinPATH/
For example in my case:
sudo ln -s /usr/libexec/gcc/x86_64-amazon-linux/4.8.5/cc1plus /usr/bin/
I needed all that, but I also needed python devel installed:
sudo yum install python-devel
How about installing pyobdc from zip file? From How to connect to Microsoft Sql Server from Ubuntu using pyODBC:
Download source vs apt-get
The apt-get utility in Ubuntu does have a version of pyODBC. (version 2.1.7).
However, it is badly out-of-date (2.1.7 vs 3.0.6) and may not work well with the newer versions of unixODBC and freetds.
This is especially important if you are trying to connect to later versions of Microsoft Sql Server (2008 onwards).
It is recommended that you use the latest versions of unixODBC, freetds and pyODBC when working with the latest Microsoft Sql Server instead of relying on packages in apt-get.
I know this is an old question, but the maintainer has a pyodbc GitHub Repo.
I also found a very good example for installing FreeTDS and setting up the config files.
Following the instructions on the GitHub docs seems to me to always be the best option. As of February, 2018, for CentOs7 (they have all flavors at the link) they say:
# Add the RHEL 6 library for Centos-7 of MSSQL driver. Centos7 uses RHEL-6 Libraries.
sudo su
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
# Uninstall if already installed Unix ODBC driver
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
# Install the msodbcsql unixODBC-utf16 unixODBC-utf16-devel driver
sudo ACCEPT_EULA=Y yum install msodbcsql
#optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel
# the Microsoft driver expects unixODBC to be here /usr/lib64/libodbc.so.1, so add soft links to the '.so.2' files
cd /usr/lib64
sudo ln -s libodbccr.so.2 libodbccr.so.1
sudo ln -s libodbcinst.so.2 libodbcinst.so.1
sudo ln -s libodbc.so.2 libodbc.so.1
# Set the path for unixODBC
export ODBCINI=/usr/local/etc/odbc.ini
export ODBCSYSINI=/usr/local/etc
source ~/.bashrc
# Prepare a temp file for defining the DSN to your database server
vi /home/user/odbcadd.txt
[MyMSSQLServer]
Driver = ODBC Driver 13 for SQL Server
Description = My MS SQL Server
Trace = No
Server = 10.100.1.10
# register the SQL Server database DSN information in /etc/odbc.ini
sudo odbcinst -i -s -f /home/user/odbcadd.txt -l
# check the DSN installation with:
odbcinst -j
cat /etc/odbc.ini
# should contain a section called [MyMSSQLServer]
# install the python driver for database connection
pip install pyodbc
For archlinux/manjaro:
sudo pacman -S unixodbc
then:
sudo pip install pyodbc
or:
pip install pyodbc
You can upgrade your pip wheel setuptools before installing pyodbc (it won't affect the pyodbc installation) also with:
sudo python -m pip install --upgrade pip wheel setuptools
or
python -m pip install --upgrade pip wheel setuptools
I used this:
yum install unixODBC.x86_64
Depending on the version of centos could change the package, you can search like this:
yum search unixodbc
I faced with same issue. For python3.6.8 and ubuntu 16.04 none of above did not help me.
sudo apt-get install python3.6-dev
This solved my problem.
These 2 commands from here worked for me in RHEL 8
sudo dnf install redhat-rpm-config gcc-c++ python3-devel unixODBC-devel
pip3 install --user pyodbc
I have unixodbc, unixodbc-dev and python3-dev all installed, but I still get
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
56 | #include <sql.h>
| ^~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-unknown-linux-gnu-gcc' failed with exit code 1
gcc and g++ are installed as well.
I'm running pop-os 22.10. I've also checked that odbc.ini and odbcinst.ini exist as well and have FreeTDS installed.

Error installing uwsgi with pip: "Python.h no such file". python-dev and python3-dev packages are installed

I'm getting the following error when trying to install uwsgi using pip on ubuntu 18.04:
$ sudo pip3 install uwsgi
...
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
I have installed the python-dev and python3-dev packages. Running locate Python.h shows that it is indeed installed:
/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h
I've tried installing using both pip and pip3, and I get the same error. Every other answer to this question points to having python-dev or python3-dev or some variant installed, and I've tried all those. Any ideas what else might cause this?
This is exactly the same problem I've faced today after I upgraded from 3.6 to 3.7.
Solve this problem by installing libpython3.7-dev:
sudo apt install libpython3.7-dev / libpython3.*-dev which version you use.
then install uwsgi again :
pip install uwsgi
the output should look like:
Building wheels for collected packages: uwsgi
Running setup.py bdist_wheel for uwsgi ... done
Stored in directory: /home/user/.cache/pip/wheels/2d/0c/b0/f3ba1bbce35c3766c9dac8c3d15d5431cac57e7a8c4111c268
Successfully built uwsgi
Installing collected packages: uwsgi, weasyprint
Successfully installed uwsgi-2.0.18 weasyprint-50
Hope this help.
These two lines did the trick for me on Linux 8.2
yum install python3-devel
pip3 install uwsgi -vvv --no-cache-dir
My python version is 3.6, I do this to solve my problem:
yum -y install python36-devel

You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application

I am working on Django project with virtualenv and connect it to local postgres database. when i run the project is says,
ImportError: No module named psycopg2.extensions
then i used this command to install
pip install psycopg2
then during the installation it gives following error.
Downloading/unpacking psycopg2==2.4.4
Downloading psycopg2-2.4.4.tar.gz (648kB): 648kB downloaded
Running setup.py (path:/home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2/setup.py) egg_info for package psycopg2
Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2
Storing debug log for failure in /home/muhammadtaqi/.pip/pip.log
Use these following commands, this will solve the error:
sudo apt-get install postgresql
then fire:
sudo apt-get install python-psycopg2
and last:
sudo apt-get install libpq-dev
I just run this command as a root from terminal and problem is solved,
sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2
or
sudo apt-get install libpq-dev python-dev
pip install psycopg2
Just install libpq-dev
$ sudo apt-get install libpq-dev
For me this simple command solved the problem:
sudo apt-get install postgresql postgresql-contrib libpq-dev python-dev
Then I can do:
pip install psycopg2
For Python 3, I did:
sudo apt install python3-dev postgresql postgresql-contrib python3-psycopg2 libpq-dev
and then I was able to do:
pip3 install psycopg2
They changed the packaging for psycopg2. Installing the binary version fixed this issue for me. The above answers still hold up if you want to compile the binary yourself.
See http://initd.org/psycopg/docs/news.html#what-s-new-in-psycopg-2-8.
Binary packages no longer installed by default. The ‘psycopg2-binary’ package must be used explicitly.
And http://initd.org/psycopg/docs/install.html#binary-install-from-pypi
So if you don't need to compile your own binary, use:
pip install psycopg2-binary
You must setup postgresql-server-dev-X.Y, where X.Y. your's servers version, and it will install libpq-dev and other servers variables at modules for server side developing.
In my case it was
apt-get install postgresql-server-dev-9.5
Reading package lists... Done
Building dependency tree Reading state information... Done The
following packages were automatically installed and are no longer
required: libmysqlclient18 mysql-common Use 'apt-get autoremove' to
remove them. The following extra packages will be installed:
libpq-dev Suggested packages: postgresql-doc-10 The following NEW
packages will be installed: libpq-dev postgresql-server-dev-9.5
In your's case
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install python-psycopg2
I was using a virtual environment on Ubuntu 18.04, and since I only wanted to install it as a client, I only had to do:
sudo apt install libpq-dev
pip install psycopg2
And installed without problems. Of course, you can use the binary as other answers said, but I preferred this solution since it was stated in a requirements.txt file.
Run the command below;
sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib
pip install psycopg2
In my case, I was facing this problem when I ran pip install -r requirements.txt to install all packages for a Django project with PostgreSQL database on an Ubuntu machine, I ran into this error and many other installation errors.
To solve this one, I ran the following commands:
sudo apt install postgresql postgresql-contrib
sudo apt install libpq-dev
sudo apt install python3-dev
sudo apt install python3-pip
sudo apt install python3-psycopg2
pip3 install psycopg2
pip3 install psycopg2-binary
Plus, also check if the Ubuntu and Python and Psycopg versions are compatible together.
Also, pip install aiopg, solve the issue when i ran into it the second time.

How do I install psycopg2 for Python 3.x?

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.

I can't install python-ldap

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

Categories