我已经将MAC OS更新到最新版本(Mojave),并安装了最新版本的XCode(10.1)。然后我安装了freetds,并使用pip安装了pymssql:
pip install pymssql
但遇到以下错误:
Collecting pymssql
Using cached https://files.pythonhosted.org/packages/2e/81/99562b93d75f3fc5956fa65decfb35b38a4ee97cf93c1d0d3cb799fffb99/pymssql-2.1.4.tar.gz
Building wheels for collected packages: pymssql
Running setup.py bdist_wheel for pymssql ... error
Complete output from command /Users/dreamteam/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/n5/z6rt8r7157vfmnp53_362dbm0000gn/T/pip-install-GRuqJN/pymssql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/n5/z6rt8r7157vfmnp53_362dbm0000gn/T/pip-wheel-dIWT59 --python-tag cp27:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
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
setup.py: include_dirs = ['/usr/local/include']
setup.py: library_dirs = ['/usr/local/lib']
running bdist_wheel
running build
running build_ext
cythoning src/_mssql.pyx to src/_mssql.c
building '_mssql' extension
creating build
creating build/temp.macosx-10.5-x86_64-2.7
creating build/temp.macosx-10.5-x86_64-2.7/src
gcc -fno-strict-aliasing -I/Users/dreamteam/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/Users/dreamteam/anaconda/include/python2.7 -c src/_mssql.c -o build/temp.macosx-10.5-x86_64-2.7/src/_mssql.o -DMSDBLIB
src/_mssql.c:30443:32: warning: unused function '__Pyx_PyUnicode_FromString' [-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
src/_mssql.c:332:29: warning: unused function '__Pyx_Py_UNICODE_strlen' [-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
^
src/_mssql.c:30620:33: warning: unused function '__Pyx_PyInt_FromSize_t' [-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
src/_mssql.c:29177:27: warning: function '__Pyx_PyInt_As_long' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
src/_mssql.c:29361:27: warning: function '__Pyx_PyInt_As_char' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
^
5 warnings generated.
creating build/lib.macosx-10.5-x86_64-2.7
gcc -bundle -undefined dynamic_lookup -L/Users/dreamteam/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/src/_mssql.o -L/usr/local/lib -L/Users/dreamteam/anaconda/lib -lsybdb -o build/lib.macosx-10.5-x86_64-2.7/_mssql.so
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pymssql
Running setup.py clean for pymssql
Failed to build pymssql
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command /Users/dreamteam/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/n5/z6rt8r7157vfmnp53_362dbm0000gn/T/pip-install-GRuqJN/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 /private/var/folders/n5/z6rt8r7157vfmnp53_362dbm0000gn/T/pip-record-xd5_kP/install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
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
setup.py: include_dirs = ['/usr/local/include']
setup.py: library_dirs = ['/usr/local/lib']
running install
running build
running build_ext
cythoning src/_mssql.pyx to src/_mssql.c
building '_mssql' extension
creating build
creating build/temp.macosx-10.5-x86_64-2.7
creating build/temp.macosx-10.5-x86_64-2.7/src
gcc -fno-strict-aliasing -I/Users/dreamteam/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/Users/dreamteam/anaconda/include/python2.7 -c src/_mssql.c -o build/temp.macosx-10.5-x86_64-2.7/src/_mssql.o -DMSDBLIB
src/_mssql.c:30443:32: warning: unused function '__Pyx_PyUnicode_FromString' [-Wunused-function]
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
^
src/_mssql.c:332:29: warning: unused function '__Pyx_Py_UNICODE_strlen' [-Wunused-function]
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
^
src/_mssql.c:30620:33: warning: unused function '__Pyx_PyInt_FromSize_t' [-Wunused-function]
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
^
src/_mssql.c:29177:27: warning: function '__Pyx_PyInt_As_long' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
^
src/_mssql.c:29361:27: warning: function '__Pyx_PyInt_As_char' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
^
5 warnings generated.
creating build/lib.macosx-10.5-x86_64-2.7
gcc -bundle -undefined dynamic_lookup -L/Users/dreamteam/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/src/_mssql.o -L/usr/local/lib -L/Users/dreamteam/anaconda/lib -lsybdb -o build/lib.macosx-10.5-x86_64-2.7/_mssql.so
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
我尝试了链接freetds软件包,但是没有用。此错误与XCode版本有关吗?如何解决? (Python版本是2.7)
答案 0 :(得分:0)
该错误似乎与XCode的最新版本有关。我安装了旧版本的XCode(9.4),然后成功安装了pymssql。
答案 1 :(得分:0)
打开终端 安装Homebrew软件包管理器
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装FreeTDS模块
brew install FreeTDS
安装pymssql模块
pip3 install pymssql
希望这对您有所帮助。