My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Building  
Building pyodbc
Updated Jul 28, 2011 by mkleehammer

Overview

Obtaining Source

The source for released versions are provided in zip files on the Downloads page.

If you are going to work on pyodbc (changes are welcome!), use the git repository on github. (Even better, create a fork on github so I can easily pull changes from your fork.)

If you want an unreleased version from github but don't have git installed, choose the branch and commit you want and use the download button. It will offer you a tar or zip file.

Compiling

pyodbc is built using distutils, which comes with Python. If you have the appropriate C++ compiler installed, run the following in the pyodbc source directory:

python setup.py build

To install after a successful build:

python setup.py install

Version

pyodbc uses git tags in the format major.minor.patch for versioning. If the commit being built has a tag, such as "2.1.1", then that is used for the version. If the commit is not tagged, then it is assumed that the commit is a beta for an upcoming release. The patch number is incremented, such as "2.1.2", and the number of commits since the previous release is appended: 2.1.2-beta3.

If you are building from inside a git repository, the build script will automatically determine the correct version from the tags (using git describe).

If you downloaded the source as a zip from the Downloads page, the version will be in a PGK-INFO text file. The build script will read the version from the text file.

If the version cannot be determined for some reason, you will see a warning about this and the script will build version 2.1.0. Do not distribute this version since you won't be able to track its actual version!

Operating Systems

Windows

On Windows, you will need the appropriate Microsoft Visual C++ compiler. To build Python 2.4 or 2.5 versions, you will need the Visual Studio 2003 .NET compiler. Unfortunately there is no free version of this.

For Python 2.6 and above, you can use the free Visual C++ 2008 Express compiler. (Do not use the 2010 version! You need to use the version that your Python distribution was built with.)

You can create a Windows installer using:

python setup.py bdist_wininst

Other

To build on other operating systems, use the gcc compiler.

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
Comment by venable....@gmail.com, Dec 29, 2008

If compiling for Ubuntu (and possibly other flavors of Linux) you'll need the unixODBC-dev package.

sudo apt-get install unixODBC-dev

Comment by natraj.k...@gmail.com, Feb 16, 2009

Hi,

Sorry I did not find any way to contact you hence adding a comment here. I have an application which was developed in Python 2.3 and now they want to add MS SQL Server support to it. I was searching for the connection on windows when I came across this project. But I am not finding any installer for Python 2.3. Can you please let me know how can I connect to MS SQL Server using Python 2.3

You can contact me at natraj.kadur@gmail.com

Comment by daniel.w...@gmail.com, Apr 9, 2009

You might want to try the Google group here: http://groups.google.com/group/pyodbc

Comment by stanabe0...@gmail.com, Nov 6, 2009

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

To avoid 'no default driver specified' error when connecting to MSSQL db, I had to create /etc/odbcinst.ini and put the following entry:

[SQL Server]
Description = TDS driver (Sybase/MS SQL)
Driver      = /usr/lib/odbc/libtdsodbc.so
Setup       = /usr/lib/odbc/libtdsS.so
CPTimeout   =
CPReuse     =

Source: http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg08435.html

Comment by rsyr...@gmail.com, Feb 11, 2011
Comment by mike.dob...@gmail.com, Jan 20, 2012

What do I do wrong? I get stuck with error after

git clone https://code.google.com/p/pyodbc/
cd pyodbc
git checkout 3.0.2
python setup.py install
Traceback (most recent call last):
  File "setup.py", line 270, in <module>
    main()
  File "setup.py", line 61, in main
    version_str, version = get_version()
  File "setup.py", line 212, in get_version
    name, numbers = _get_version_git()
  File "setup.py", line 255, in _get_version_git
    branch = re.search(r'\* (\w+)', result).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Sign in to add a comment
Powered by Google Project Hosting