Install pyodbc on Centos / RHEL

Ganesh Chandrasekaran
Analytics Vidhya
Published in
1 min readSep 4, 2020

--

What is needed to install pyodbc.

Why PyODBC is needed?

To connect to any Database via Python. (There are specific drivers available for each database, pyodbc serves as a common library)

Installation using pip libraries are straight forward provided your system has all the prerequisites.

Installing pyodbc on Centos / RHEL can be challenging if you forget to have the development library.

These are must have libraries for any development work, so its better to have them installed as part of any CentOS / RHEL setup.


$ sudo yum install unixodbc-dev
$ sudo yum install unixODBC unixODBC-devel$ sudo yum install epel-release$ sudo yum install gcc-c++

These are specific to Python ODBC.

Before using pip3, make sure you have pip installed.

$ pip3 --version $ sudo yum install python3-devel$ sudo pip3 install pyodbc

The installation can be tested as follows

$ python3

>>> import pyodbc

If no errors are thrown, then your installation is perfect.

--

--

Ganesh Chandrasekaran
Analytics Vidhya

Big Data Solution Architect | Adjunct Professor. Thoughts and opinions are my own and don’t represent the companies I work for.