Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 621
IgorGanapolsky Avatar asked Jun 02 '10 18:06

IgorGanapolsky


People also ask

Does Pyodbc work on Linux?

pyodbc is a Python DB conformant module for ODBC databases. This tutorial shows how to use pyodbc with an ODBC driver, which you can download from this site. You can then connect Python on Linux and Unix to remote database such as Microsoft SQL Server, Oracle®, DB2, Microsoft Access, Sybase ASE and InterBase.

Is Pyodbc included in Python?

pyodbc is an open source Python module that makes accessing ODBC databases simple. It implements the DB API 2.0 specification but is packed with even more Pythonic convenience. Precompiled binary wheels are provided for most Python versions on Windows and macOS.


2 Answers

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 
like image 60
Jim Clouse Avatar answered Oct 06 '22 16:10

Jim Clouse


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 
like image 21
IgorGanapolsky Avatar answered Oct 06 '22 15:10

IgorGanapolsky