【问题标题】:Unable to install pyodbc or pymssql on mac sierra无法在 mac sierra 上安装 pyodbc 或 pymssql
【发布时间】:2018-03-06 01:43:23
【问题描述】:

我正在尝试使用“pip install pyodbc”和“pip install pymssql”安装 pyodbc 或 pymssql python 库。但是,我不断收到以下错误消息:

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/

我已经安装了 freetds,尽管在安装过程中我仍然收到以下消息:

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

有人知道为什么会这样吗? 我试过this solutionthis solutionthis solution

这是我当前的 FreeTDS 设置:

                        Version: freetds v0.91.112
         freetds.conf directory: /usr/local/Cellar/freetds@0.91/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

我也无法安装 unixodbc:

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

请帮忙?

【问题讨论】:

  • 您使用的是哪个版本的 Python (python --version)?你在用virtualenv吗?

标签: python pyodbc freetds pymssql


【解决方案1】:

我可以通过这样做来安装它:

  1. brew install unixodbc安装unixodbc
  2. 安装iodbc:http://www.iodbc.org/dataspace/doc/iodbc/wiki/iodbcWiki/Downloads
  3. 安装MySQL驱动:https://dev.mysql.com/downloads/connector/odbc/
  4. 使用myodbc-installer -a -d -n "MySQL ODBC 5.3 Driver" -t "Driver=/usr/local/lib/libmyodbc5w.so"添加驱动程序
  5. 看到/Library/ODBC/odbc.ini/Library/ODBC/odbcinst.ini 已更新
  6. 现在将 unixodbc 的 odbcinst.ini/odbc.ini 文件改为使用 iodbc ini 文件:
  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. 安装pyodbc:pip3 install pyodbc
  10. 启动 python shell (python3) 并检查是否可以找到驱动程序 (import pyodbc;pyodbc.drivers())

我希望这可以帮助某人。

【讨论】:

    猜你喜欢
    • 2022-07-12
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    • 1970-01-01
    • 2016-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多