代码之家  ›  专栏  ›  技术社区  ›  roadfar

在macosmojave上安装pymssql遇到问题

  •  1
  • roadfar  · 技术社区  · 8 年前

    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)

    1 回复  |  直到 7 年前
        1
  •  0
  •   roadfar    8 年前

    这个错误似乎与最新版本的XCode有关。我安装了旧版本的XCode(9.4),然后成功地安装了pymssql。

        2
  •  0
  •   Tung Nguyen    7 年前

    安装自制软件包管理器

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
    

    安装FreeTDS模块

    brew install FreeTDS  
    

    pip3 install pymssql
    

    希望这对你们有帮助。