Sakura
Sakura

Reputation: 969

Unable to install pyodbc or pymssql on mac sierra

I am trying to install pyodbc or pymssql python library using "pip install pyodbc" and "pip install pymssql". However, I keep getting the following error message:

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/mz/2w0c0vc93bb2qy5rmrnxn85h0000gn/T/pip-build-upWR3q/pymssql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/mz/2w0c0vc93bb2qy5rmrnxn85h0000gn/T/pip-DUorxp-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/mz/2w0c0vc93bb2qy5rmrnxn85h0000gn/T/pip-build-upWR3q/pymssql/

I already have freetds installed although I am still getting the following message during installation:

setup.py: Detected Darwin/Mac OS X.
        You can install FreeTDS with Homebrew or MacPorts, or by downloading
        and compiling it yourself.

        Homebrew (http://brew.sh/)
        --------------------------
        brew install freetds

        MacPorts (http://www.macports.org/)
        -----------------------------------
        sudo port install freetds

    setup.py: Not using bundled FreeTDS

Anyone had any idea why is that so? I tried this solution, this solution and this solution.

This is my current FreeTDS settings:

                        Version: freetds v0.91.112
         freetds.conf directory: /usr/local/Cellar/[email protected]/0.91.112/etc
 MS db-lib source compatibility: no
    Sybase binary compatibility: no
                  Thread safety: yes
                  iconv library: yes
                    TDS version: 7.1
                          iODBC: no
                       unixodbc: no
          SSPI "trusted" logins: no
                       Kerberos: no

I can't install unixodbc either:

pip install unixodbc
Collecting unixodbc
  Could not find a version that satisfies the requirement unixodbc (from versions: )
No matching distribution found for unixodbc

Please help?

Upvotes: 0

Views: 1329

Answers (1)

stianlagstad
stianlagstad

Reputation: 3302

I was able to install it by doing this:

  1. Install unixodbc with brew install unixodbc
  2. Install iodbc: http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads
  3. Install the MySQL driver: https://dev.mysql.com/downloads/connector/odbc/
  4. Add the driver with myodbc-installer -a -d -n "MySQL ODBC 5.3 Driver" -t "Driver=/usr/local/lib/libmyodbc5w.so"
  5. See that /Library/ODBC/odbc.ini and /Library/ODBC/odbcinst.ini have been updated
  6. Now point unixodbc's odbcinst.ini/odbc.ini files to instead use the iodbc ini files:
  7. sudo rm /usr/local/Cellar/unixodbc/2.3.4/etc/odbc.ini && sudo ln -s /Library/ODBC/odbc.ini /usr/local/Cellar/unixodbc/2.3.4/etc/odbc.ini
  8. sudo rm /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini && sudo ln -s /Library/ODBC/odbcinst.ini /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini .
  9. Install pyodbc: pip3 install pyodbc.
  10. Launch a python shell (python3) and check that you can find the driver (import pyodbc;pyodbc.drivers())

I hope this can help someone.

Upvotes: 1

Related Questions