cancel
Showing results for 
Search instead for 
Did you mean: 

python3 cannot import sqlanydb

Former Member
0 Kudos
9,814

I installed SQL Anywhere 16. How to solve the following issue?

$ cat ~/.bashrc 
export SQLANYWHERE_HOME=/Applications/SQLAnywhere16/System
export DYLD_LIBRARY_PATH=$SQLANYWHERE_HOME/lib64:$SQLANYWHERE_HOME/lib32:$DYLD_LIBRARY_PATH
export DYLD_BIND_AT_LAUNCH=1
export PATH=$PATH:$SQLANYWHERE_HOME/bin64:$SQLANYWHERE_HOME/bin32


$ python3

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 01:12:57) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlanydb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./sqlanydb.py", line 469, in <module>
    class Connection(object):
  File "./sqlanydb.py", line 471, in Connection
    def __init__(self, args, kwargs, parent = Root("PYTHON")):
  File "./sqlanydb.py", line 422, in __init__
    'libdbcapi_r.dylib')
  File "./sqlanydb.py", line 416, in load_library
    raise InterfaceError("Could not load dbcapi.  Tried: " + ','.join(names))
sqlanydb.InterfaceError: Could not load dbcapi.  Tried: dbcapi.dll,libdbcapi_r.so,libdbcapi_r.dylib

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

This is because sqlanydb is looking for the 32-bit version of dbcapi.dll which is not installed if you've only installed the 64-bit version of SQLAny. Try reinstalling and selecting both versions.

Former Member
0 Kudos

Mike, thanks. I re-installed (run uninstall.sh from /Applications/SQLAnywhere16/), but it doesn't work. My system is Mac OS X 10.10.

Former Member

Have you sourced the sa_config.sh file, which will be in:

./Applications/SQLAnywhere16/System/bin32/sa_config.sh

or somewhere similar to that?

Former Member
0 Kudos

$ cd /Applications/SQLAnywhere16/System/bin32/

$ pwd

/Applications/SQLAnywhere16/System/bin32

$ chmod +x sa_config.sh

$ ./sa_config.sh

It does not show any message. What should be in the output?

Former Member
0 Kudos

I'm not near a 'nix box at the moment, but I don't think there should be any output. What happens now if you try to import sqlanydb in the Python REPL?

Answers (2)

Answers (2)

graeme_perrow
Advisor
Advisor

$ chmod +x sa_config.sh

$ ./sa_config.sh

You can't execute it this way; this creates a new shell (environment), sets a bunch of environment variables, and then drops the environment, and so it has no effect. Use ". <path>/sa_config.sh". Note the space after the dot. This sets the environment variables in the current shell.

Former Member

$ . /Applications/SQLAnywhere16/System/bin32/sa_config.sh

It seems to work. Mike and Graeme, thanks!

Former Member
0 Kudos

I have the same problem. I have sourced that .sh file and both 32 and 64 bit are installed and available in the path. Though it doesn't work. Any ideas? Mac os X 10.10

Former Member
0 Kudos

Did you execute the command in the way Graeme Perrow proposed?