Compiling pyodbc v3 on Ubuntu

68 views
Skip to first unread message

Gabe

unread,
Aug 28, 2010, 12:43:40 AM8/28/10
to pyodbc
Hi,

I'm trying to compile the python3 version but I'm running into some
troubles.

After installing the unixODBC-dev I tried:

python3 setup.py build

and got:


running build
running build_ext
building 'pyodbc' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-
prototypes -fPIC -DPYODBC_MAJOR=3 -DPYODBC_MINOR=1 -DPYODBC_MICRO=1 -
DPYODBC_BUILD=1 -I/usr/include/python3.1 -c /home/gabe/dev/python/
pyodbc/src/params.cpp -o build/temp.linux-x86_64-3.1/home/gabe/dev/
python/pyodbc/src/params.o -Wno-write-strings
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
/usr/include/python3.1/datetime.h:185: warning: ‘PyDateTimeAPI’
defined but not used
/home/gabe/dev/python/pyodbc/src/params.cpp:12: warning:
‘decimalFormat’ defined but not used
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-
prototypes -fPIC -DPYODBC_MAJOR=3 -DPYODBC_MINOR=1 -DPYODBC_MICRO=1 -
DPYODBC_BUILD=1 -I/usr/include/python3.1 -c /home/gabe/dev/python/
pyodbc/src/errors.cpp -o build/temp.linux-x86_64-3.1/home/gabe/dev/
python/pyodbc/src/errors.o -Wno-write-strings
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
/usr/include/python3.1/datetime.h:185: warning: ‘PyDateTimeAPI’
defined but not used
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-
prototypes -fPIC -DPYODBC_MAJOR=3 -DPYODBC_MINOR=1 -DPYODBC_MICRO=1 -
DPYODBC_BUILD=1 -I/usr/include/python3.1 -c /home/gabe/dev/python/
pyodbc/src/getdata.cpp -o build/temp.linux-x86_64-3.1/home/gabe/dev/
python/pyodbc/src/getdata.o -Wno-write-strings
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-
prototypes -fPIC -DPYODBC_MAJOR=3 -DPYODBC_MINOR=1 -DPYODBC_MICRO=1 -
DPYODBC_BUILD=1 -I/usr/include/python3.1 -c /home/gabe/dev/python/
pyodbc/src/sqlwchar.cpp -o build/temp.linux-x86_64-3.1/home/gabe/dev/
python/pyodbc/src/sqlwchar.o -Wno-write-strings
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
/home/gabe/dev/python/pyodbc/src/sqlwchar.cpp: In member function
‘bool SQLWChar::Convert(PyObject*)’:
/home/gabe/dev/python/pyodbc/src/sqlwchar.cpp:40: error: cannot
convert ‘SQLWCHAR*’ to ‘Py_UNICODE*’ in initialization
/home/gabe/dev/python/pyodbc/src/sqlwchar.cpp: In function ‘PyObject*
PyUnicode_FromSQLWCHAR(const SQLWCHAR*, Py_ssize_t)’:
/home/gabe/dev/python/pyodbc/src/sqlwchar.cpp:91: error: cannot
convert ‘const SQLWCHAR*’ to ‘const Py_UNICODE*’ for argument ‘1’ to
‘PyObject* PyUnicodeUCS4_FromUnicode(const Py_UNICODE*, Py_ssize_t)’
/usr/include/python3.1/datetime.h: At global scope:
/usr/include/python3.1/datetime.h:185: warning: ‘PyDateTimeAPI’
defined but not used
error: command 'gcc' failed with exit status 1


I have no idea what's happening and my google search wasn't much
useful...

On windows, using cygwin, I installed it without any issues, if that's
any help.

Thanks,
- Gabriel

mkleehammer

unread,
Aug 28, 2010, 3:45:49 PM8/28/10
to pyodbc
FYI: I'm working on a test system for this. Apparently both of mine
that I usually build with (Windows 32-bit and Windows 64-bit) have
Py_UNICODE and SQLWCHAR set to the same size. I could build Python
myself with UCS4, but I thought it would be easier to get a Linux
server back up. If I'm not mistaken, most Linux distributions use
UCS4.

If you are looking for a quick fix: the sqlwchar.cpp:40 fix is that pU
should have been declared as a Py_UNICODE*, not SQLWCHAR*. Line 91
just needs a cast to (const Py_UNICODE*).

Gabe

unread,
Aug 28, 2010, 5:55:20 PM8/28/10
to pyodbc
Thanks, the fix got me through compilation, but now I can't import the
module into python3

This is what I get:


Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function
(PyInit_pyodbc)


I didn't see any errors during build or install

-Gabriel
Reply all
Reply to author
Forward
0 new messages