Note that there are some explanatory texts on larger screens.

plurals
  1. POpyodbc error: unixODBC can't open Microsoft ODBC driver, running on Apache RHEL
    text
    copied!<p>Trying to port my proof-of-concept, Python-driven web page (which is currently hosted on my Windows 7 laptop running IIS) to a LAMP setup on the Amazon cloud. From my Amazon EC2 RHEL6 server, my pyodbc calls are failing when my Python modules are called by Apache, although I can run the same modules myself from the command line and they return data from my SQL-Server-based RDS server as designed. </p> <p>I started with a clean RHEL 6 install, then installed unixODBC, the Microsoft ODBC Driver 11, and pyodbc. My Python modules are installed in /var/www/cgi-bin. I have a "hello.py" module there as well, which I can successfully invoke from the Web. But when my browser runs the Python with the pyodbc call, I get a 500 error and the following Python stack trace in /etc/httpd/conf/httpd.conf:</p> <pre><code>[Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] Traceback (most recent call last): [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] File "/var/www/cgi-bin/emit_message_count_timeline.py", line 92, in &lt;module&gt; [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] date_end=date_end, loco_id=loco_id, normalized=normalized) [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] File "/var/www/cgi-bin/emit_message_count_timeline.py", line 19, in emit_message_count_timeline [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] date_end=date_end, loco_id=loco_id, normalized=normalized) [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] File "/var/www/cgi-bin/ServeChartData.py", line 617, in query_message_count_timeline [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] conn = create_db_connection() [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] File "/var/www/cgi-bin/ServeChartData.py", line 42, in create_db_connection [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] conn = pyodbc.connect(conn_string) [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0' : file not found (0) (SQLDriverConnect)") [Tue Nov 19 13:09:31 2013] [error] [client 108.41.105.79] Premature end of script headers: emit_message_count_timeline.py </code></pre> <p>The ODBC driver should be callable by any user:</p> <pre><code>[ec2-user@(...)]$ ls -l /opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0 -rwxr-xr-x. 1 root root 1757680 Nov 15 15:37 /opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0 </code></pre> <p>UPDATE 2013-11-20:</p> <pre><code>[ec2-user@(...) ~]$ cat /etc/odbcinst.ini [ODBC Driver 11 for SQL Server] Description=Microsoft ODBC Driver 11 for SQL Server Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0 Threading=1 UsageCount=1 </code></pre> <p>UPDATE 2013-11-21: All of the driver's dependencies seem to be intact:</p> <pre><code>[ec2-user@domU-12-31-39-09-4A-9D tmp]$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0 linux-vdso.so.1 =&gt; (0x00007fff736a7000) libcrypto.so.10 =&gt; /usr/lib64/libcrypto.so.10 (0x00007feacdaa2000) libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007feacd89e000) librt.so.1 =&gt; /lib64/librt.so.1 (0x00007feacd695000) libssl.so.10 =&gt; /usr/lib64/libssl.so.10 (0x00007feacd438000) libuuid.so.1 =&gt; /lib64/libuuid.so.1 (0x00007feacd234000) libodbcinst.so.1 =&gt; /usr/lib64/libodbcinst.so.1 (0x00007feacd01c000) libkrb5.so.3 =&gt; /lib64/libkrb5.so.3 (0x00007feaccd36000) libgssapi_krb5.so.2 =&gt; /lib64/libgssapi_krb5.so.2 (0x00007feaccaf2000) libstdc++.so.6 =&gt; /usr/lib64/libstdc++.so.6 (0x00007feacc7eb000) libm.so.6 =&gt; /lib64/libm.so.6 (0x00007feacc567000) libgcc_s.so.1 =&gt; /lib64/libgcc_s.so.1 (0x00007feacc351000) libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007feacc133000) libc.so.6 =&gt; /lib64/libc.so.6 (0x00007feacbda0000) libz.so.1 =&gt; /lib64/libz.so.1 (0x00007feacbb8a000) /lib64/ld-linux-x86-64.so.2 (0x00000034f0c00000) libcom_err.so.2 =&gt; /lib64/libcom_err.so.2 (0x00007feacb985000) libk5crypto.so.3 =&gt; /lib64/libk5crypto.so.3 (0x00007feacb759000) libkrb5support.so.0 =&gt; /lib64/libkrb5support.so.0 (0x00007feacb54e000) libkeyutils.so.1 =&gt; /lib64/libkeyutils.so.1 (0x00007feacb34a000) libresolv.so.2 =&gt; /lib64/libresolv.so.2 (0x00007feacb130000) libselinux.so.1 =&gt; /lib64/libselinux.so.1 (0x00007feacaf10000) </code></pre> <p>EDIT 2013-12-02: In case it helps, here's an oddity. In my Apache config file, /etc/httpd/conf/httpd.conf, I am setting the following two environment variables:</p> <pre><code>SetEnv LD_LIBRARY_PATH /lib64:/usr/lib64:/opt/microsoft/msodbcsql/lib64 SetEnv LIBPATH /lib64:/usr/lib64:/opt/microsoft/msodbcsql/lib64 </code></pre> <p>but when I write a simple Python CGI script to to print out all the environment variables, of these two I see only LIBPATH:</p> <p>Code:</p> <pre><code>#!/usr/bin/python import os print "Content-type: text/plain" print print "Hello, world of Apache Python" for key in sorted(os.environ.iterkeys()): print key, os.environ[key] </code></pre> <p>Output in my browser (blank line and all):</p> <pre><code>Hello, world of Apache Python DOCUMENT_ROOT /opt/cosmalogs/www GATEWAY_INTERFACE CGI/1.1 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 HTTP_ACCEPT_ENCODING gzip,deflate,sdch HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8 HTTP_CONNECTION keep-alive HTTP_HOST ec2-107-22-64-71.compute-1.amazonaws.com HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36 LIBPATH /lib64:/usr/lib64:/opt/microsoft/msodbcsql/lib64 PATH /sbin:/usr/sbin:/bin:/usr/bin QUERY_STRING REMOTE_ADDR 184.75.42.178 REMOTE_PORT 4765 REQUEST_METHOD GET REQUEST_URI /cgi-bin/hello.py SCRIPT_FILENAME /var/www/cgi-bin/hello.py SCRIPT_NAME /cgi-bin/hello.py SERVER_ADDR 10.236.176.197 SERVER_ADMIN root@localhost SERVER_NAME ec2-107-22-64-71.compute-1.amazonaws.com SERVER_PORT 80 SERVER_PROTOCOL HTTP/1.1 SERVER_SIGNATURE &lt;address&gt;Apache/2.2.15 (Red Hat) Server at ec2-107-22-64-71.compute-1.amazonaws.com Port 80&lt;/address&gt; SERVER_SOFTWARE Apache/2.2.15 (Red Hat) </code></pre> <p>EDIT 2013-12-05: I am not really sure the cause of the problem, but running strace with the -f option to include forked (child) processes, I may have traced the problem to the following lines in the child process that is presumably Python. It doesn't explain why Python is reporting "file not found," however:</p> <pre><code>[pid 2006] open("/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0", O_RDONLY) = 3 [pid 2006] read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&gt;\0\1\0\0\0\340$\2\0\0\0\0\0@\0\0\0\0\0\0\0\260\312\32\0\0\0\0\0\0\0\0\0@\0008\0\6\0@\0\35\0\34\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\350\347\30\0\0\0\0\0\350\347\30\0\0\0\0\0\0\0 \0\0\0\0\0\1\0\0\0\6\0\0\0\350\347\30\0\0\0\0\0\350\3478\0\0\0\0\0\350\3478\0\0\0\0\0l\341\1\0\0\0\0\0\240B\2\0\0\0\0\0\0\0 \0\0\0\0\0\2\0\0\0\6\0\0\0\210\310\31\0\0\0\0\0\210\3109\0\0\0\0\0\210\3109\0\0\0\0\0@\2\0\0\0\0\0\0@\2\0\0\0\0\0\0\10\0\0\0\0\0\0\0\4\0\0\0\4\0\0\0\220\1\0\0\0\0\0\0\220\1\0\0\0\0\0\0\220\1\0\0\0\0\0\0$\0\0\0\0\0\0\0$\0\0\0\0\0\0\0\4\0\0\0\0\0\0\0P\345td\4\0\0\0\2200\27\0\0\0\0\0\2200\27\0\0\0\0\0\2200\27\0\0\0\0\0&lt;&lt;\0\0\0\0\0\0&lt;&lt;\0\0\0\0\0\0\4\0\0\0\0\0\0\0Q\345td\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\0\0\0\0\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\372N\2K\251&amp;{\230\244\272@\255f\3a\270t\352\377\231\0\0\0\0a\0\0\0\1\1\0\0\20\0\0\0\n\0\0\0\0 P\10 \1\0\0\0\204\10 \200\0\20\0\200\0\10\205\rP\0\250\24\4\260@\0\20\0\250\6A\206\0@\0\2\0h\200\6\0\200\0\2\0\224\"\300!\t 0\211\2\0\4\21\2\300\201\f\4\201\t\200\0\20\300\1\10\240\24h\2\242X$\2\0\200\2\0\1\20\20\240\200\20h\30\10\10\10*H%\304\20\23@Y\0\260\300\4\0\30@@\1\10\4\0\200\0\0\t\0\20\0N\22\206\220\204\1\1\0\0\0\0\0\0\3\1\0\0\0\0\0\0\0\0\0\0\5\1\0\0\6\1\0\0\0\0\0\0\10\1\0\0\n\1\0\0\v\1\0\0\0\0\0\0\f\1\0\0\r\1\0\0\17\1\0\0\20\1\0\0\21\1\0\0\22\1\0\0\24\1\0\0\26\1\0\0\27\1\0\0\30\1\0\0\0\0\0\0\31\1\0\0\33\1\0\0\35\1\0\0\0\0\0\0\37\1\0\0\0\0\0\0 \1\0\0!\1\0\0#\1\0\0%\1\0\0&amp;\1\0\0\0\0\0\0\0\0\0\0(\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0*\1\0\0+\1\0\0\0\0\0\0\0\0\0\0-\1\0\0/\1\0\0001\1\0\0004\1\0\0006\1\0\0007\1\0\0009\1\0\0:\1\0\0&lt;\1\0\0=\1\0\0&gt;\1\0\0\0\0\0\0\0\0\0\0@\1\0\0A\1\0\0B\1\0\0C\1\0\0", 832) = 832 [pid 2006] fstat(3, {st_mode=S_IFREG|0755, st_size=1757680, ...}) = 0 [pid 2006] mmap(NULL, 3877512, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = -1 EACCES (Permission denied) [pid 2006] close(3) = 0 </code></pre> <p>Thank you for any help! BH</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload