如何在 MacOS Sierra 上安装 pymssql
How to install pymssql on MacOS Sierra
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-J1I0ox/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 /tmp/pip-qmtdBW-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-J1I0ox/pymssql/
我遇到与 显示相同的错误。我按照该页面上的说明尝试 brew install freetds
然后是 sudo -H pip install pymssql
.
生成此错误代码:
_mssql.c:18814:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
4 warnings and 1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-J1I0ox/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 /tmp/pip-qmtdBW-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-J1I0ox/pymssql/
搜索此错误将我带到 。我通过尝试 brew unlink freetds; brew install homebrew/versions/freetds091
和 brew uninstall freetds; brew install homebrew/versions/freetds091
来遵循那里发布的解决方案,这在尝试 sudo -H pip install pymssql
:
时会产生不同的错误
_mssql.c:266:10: fatal error: 'sqlfront.h' file not found
#include "sqlfront.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-build-97A9sQ/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/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-0nUZo4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-build-97A9sQ/pymssql/
于是我放弃并尝试安装pyodbc,但我仍然得到类似的错误: src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
#include sql.h
任何帮助都将非常有用。
This link 最终解决了我的问题。对于遇到这些问题的任何其他人,这一系列命令对我有用。
brew uninstall --force freetds
brew install freetds@0.91
brew link --force freetds@0.91
pip install pymssql
截至 2021 年 2 月
我无法再安装 freetds@0.91,因为自制软件没有它。 freetds 的当前版本是 1.2.18,brew link --force freetds
似乎没有任何变化。
根本问题 'sqlfront.h' file not found
是由于 freetds 文件在安装过程中没有正确链接。我们可以通过
来解决这个问题
export LDFLAGS="-L/opt/homebrew/opt/freetds/lib"
export CPPFLAGS="-I/opt/homebrew/opt/freetds/include"
pip install pymssql
其中 /opt/homebrew/opt/freetds
是 homebrew 在您的系统上安装 freetds 的位置(我在 Apple Silicon 上),可能与您不同。如果您使用的是 Intel,您的可能看起来像 /usr/local/opt/freetds
.
要准确找到 homebrew 在您的系统上安装 freetds(或与此相关的任何程序)的位置,您可以这样做
brew --prefix freetds
这应该 return 类似于 /opt/homebrew/opt/freetds
或 /opt/homebrew/opt/freetds@1.2.18
。您可以忽略任何版本号并附加 /lib
和 /include
以获得您需要的路径。
这是一个需要牢记的小技巧,因为它适用于通过自制软件安装依赖项的许多其他安装问题。
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-J1I0ox/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 /tmp/pip-qmtdBW-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-J1I0ox/pymssql/
我遇到与 brew install freetds
然后是 sudo -H pip install pymssql
.
生成此错误代码:
_mssql.c:18814:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
4 warnings and 1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-J1I0ox/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 /tmp/pip-qmtdBW-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-J1I0ox/pymssql/
搜索此错误将我带到 brew unlink freetds; brew install homebrew/versions/freetds091
和 brew uninstall freetds; brew install homebrew/versions/freetds091
来遵循那里发布的解决方案,这在尝试 sudo -H pip install pymssql
:
_mssql.c:266:10: fatal error: 'sqlfront.h' file not found
#include "sqlfront.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-build-97A9sQ/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/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-0nUZo4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/_s/27xppw4j3yl78c9l4v1w3n9m0000gn/T/pip-build-97A9sQ/pymssql/
于是我放弃并尝试安装pyodbc,但我仍然得到类似的错误: src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
#include sql.h
任何帮助都将非常有用。
This link 最终解决了我的问题。对于遇到这些问题的任何其他人,这一系列命令对我有用。
brew uninstall --force freetds
brew install freetds@0.91
brew link --force freetds@0.91
pip install pymssql
截至 2021 年 2 月
我无法再安装 freetds@0.91,因为自制软件没有它。 freetds 的当前版本是 1.2.18,brew link --force freetds
似乎没有任何变化。
根本问题 'sqlfront.h' file not found
是由于 freetds 文件在安装过程中没有正确链接。我们可以通过
export LDFLAGS="-L/opt/homebrew/opt/freetds/lib"
export CPPFLAGS="-I/opt/homebrew/opt/freetds/include"
pip install pymssql
其中 /opt/homebrew/opt/freetds
是 homebrew 在您的系统上安装 freetds 的位置(我在 Apple Silicon 上),可能与您不同。如果您使用的是 Intel,您的可能看起来像 /usr/local/opt/freetds
.
要准确找到 homebrew 在您的系统上安装 freetds(或与此相关的任何程序)的位置,您可以这样做
brew --prefix freetds
这应该 return 类似于 /opt/homebrew/opt/freetds
或 /opt/homebrew/opt/freetds@1.2.18
。您可以忽略任何版本号并附加 /lib
和 /include
以获得您需要的路径。
这是一个需要牢记的小技巧,因为它适用于通过自制软件安装依赖项的许多其他安装问题。