Unable to install pyodbc on Linux

Posted on

Question :

Unable to install pyodbc on Linux

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?

Answer #1:

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
Answered By: Jim Clouse

Answer #2:

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
Answered By: IgorGanapolsky

Answer #3:

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 g++
apt-get install unixodbc-dev
pip install pyodbc
Answered By: Alexis.Rolland

Answer #4:

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
Answered By: Jeevan Chaitanya

Answer #5:

Struggled with the same issue

After running:
sudo apt-get install unixodbc-dev

I was able to pip install pyodbc

Answered By: Cornelis Kuijpers

Answer #6:

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
Answered By: user2550587

Answer #7:

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

Answered By: cammil

Answer #8:

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++
Answered By: Andy Madge

Leave a Reply

Your email address will not be published. Required fields are marked *