Search code examples
python-2.7pyodbcundefined-symbol

centos pyodbc stopped working. Error: pyodbc.so: undefined symbol: PyUnicodeUCS2_From_Object


As I needed to add some libraries to Python2.7 on CentOS, I decided to rebuild Python. However, since I've done this, pyodbc doesnt work anymore and shows the following error when trying to import pyodbc

 >>> import pyodbc
/usr/local/lib/python2.7/site-packages/pyodbc-3.0.7-py2.7-linux-x86_64.egg/pyodbc.py:3: UserWarning: Module pyodbc was already imported from /usr/local/lib/python2.7/site-packages/pyodbc-3.0.7-py2.7-linux-x86_64.egg/pyodbc.pyc, but /mnt/fastArray0/user/Roel/Development/django/pyodbc-3.0.7 is being added to sys.path
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/pyodbc.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/pyodbc.py", line 6, in __bootstrap__
ImportError: /root/.python-eggs/pyodbc-3.0.7-py2.7-linux-x86_64.egg-tmp/pyodbc.so: undefined symbol: PyUnicodeUCS2_FromObject

I reinstalled pyodbc, reinstalled all dependencies but the issue persists. Also, I checked the new libraries I added to Python but i really doubt that packages like pytz won't affect pyodbc at all.

Furthermore, all other libraries are still working fine. It is just pyodbc which really doesn't like to work anymore.


Solution

  • We finally found out what was wrong. I had build Python the wrong way. I used the flag --enable-unicode=ucs4 while I shouldnt have used it. pyodbc doesn't like this at all so that is why it kept on crashing.