Search code examples
pythonpyodbcmsys2

msys2 won't recognize driver folder as valid


I have a python program that uses an ODBC connection, so needs to locate the database drivers. Since I couldn't get pyodbc to install on my mingw64 version of python (I'm told pyodbc has hardcoded MSVC flags making it very difficult to do), I instead am using a regular windows python install that I'm running from within msys2 by just altering my path to point to that python install (maybe there is more that I should be doing to target a different python install?)

Now the problem I'm running into is that while the program runs fine in powershell using that version of python, when I try running it within msys2 I get the following error:

conn = pyodbc.connect(link)

pyodbc.InterfaceError: ('IM003', '[IM003] Specified driver could not be
loaded due to system error  126: The specified module could not be found.
(Teradata, C:\\Program Files\\Teradata\\Client\\14.10\\ODBC Driver for
Teradata nt-x8664\\Lib\\tdata32.dll). (160) (SQLDriverConnect)')

The thing is that directory is correct and I can even run

cd "C:\\Program Files\\Teradata\\Client\\14.10\\ODBC Driver for Teradata nt-x8664\\Lib\\"

from within msys2 and it works just fine and recognizes that directory as valid and it contains a file named tdata32.dll. Using winpty python myprogram.py didn't resolve this either.

So why can't my system find this driver directory but only when I'm running the python program from msys2?


Solution

  • I suspect that tdata32.dll depends on other DLLs, and one of them is not being found because it is not on the PATH when you run Python from MSYS2.

    Try adding a line of Python code to print the contents of your PATH environment variable in both environments to examine the issue.

    You can also use Dependency Walker to see what DLLs tdata32.dll depends on.