在Mac OS X Lion上安装pymssql时出错

时间:2022-06-19 22:44:43

I have XCode installed and also FreeTDS. I tried to connect to my SQL Server and it works perfect.

我安装了XCode,还安装了FreeTDS。我试图连接到我的SQL Server,它的工作完美。

Now I have to develop an aplication on python that works with this SQL Server and I´m trying to install pymsql, but I got this error when I launche sudo python setup.py command:

现在我必须在python上开发一个与这个SQL Server一起使用的应用程序,我正在尝试安装pymsql,但是当我启动sudo python setup.py命令时出现了这个错误:

==> sudo python setup.py install
running install
running bdist_egg
running egg_info
writing pymssql.egg-info/PKG-INFO
writing top-level names to pymssql.egg-info/top_level.txt
writing dependency_links to pymssql.egg-info/dependency_links.txt
reading manifest file 'pymssql.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-intel/egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/sw/include -Ifreetds/nix_64/include -I/opt/local/include -I/opt/local/include/freetds -I/opt/local/freetds/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.7-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_convert_python_value’:
_mssql.c:7322: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_get_result’:
_mssql.c:9554: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c:9566: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_pf_6_mssql_20MSSQLStoredProcedure_2bind’:
_mssql.c:11146: warning: implicit conversion shortens 64-bit value into a 32-bit value
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/_mssql.o -L/sw/lib -Lfreetds/nix_64/lib -L/opt/local/lib -L/opt/local/lib/freetds -L/opt/local/freetds/lib -lsybdb -lrt -o build/lib.macosx-10.7-intel-2.7/_mssql.so
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//cc6eQsIN.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1

Any help or clue?

任何帮助或线索?

3 个解决方案

#1


11  

Unfortunately, pymssql's setup.py (as of version pymssql-2.0.0b1-dev-20111019) needs a bit of help to work properly on OSX Lion. The current setup.py tries to compile/link against some pre-built Linux FreeTDS libraries, and also tries to link against librt, which doesn't exist on OSX. Additionally, it only explicitly looks for FreeTDS libraries from Fink or MacPorts, so if you've installed Homebrew (if you use if) or FreeTDS itself in a non-standard location, it may not be located by compiler/linker.

不幸的是,pymssql的setup.py(从版本pymssql-2.0.0b1-dev-20111019开始)需要一些帮助才能在OSX Lion上正常工作。当前的setup.py尝试编译/链接一些预构建的Linux FreeTDS库,并尝试链接librt,这在OSX上不存在。此外,它只显示从Fink或MacPorts中查找FreeTDS库,因此如果您在非标准位置安装了Homebrew(如果使用if)或FreeTDS本身,则编译器/链接器可能无法找到它。

I created a repaired version of setup.py here. It worked well enough for me with the Homebrew build of FreeTDS using the standard locations (/usr/local/{lib, include}), but as always YMMV. You may need to adjust setup.py further if you've installed FreeTDS in a different location. You can generally ignore the warnings from the linker about missing directories that may not exist on your system:

我在这里创建了一个修复过的setup.py版本。使用标准位置(/ usr / local / {lib,include}),FreebDS的Homebrew构建对我来说效果很好,但总是YMMV。如果您在其他位置安装了FreeTDS,则可能需要进一步调整setup.py。您通常可以忽略链接器中有关系统上可能不存在的缺少目录的警告:

ld: warning: directory not found for option '-L/usr/local/lib/freetds'

ld:警告:找不到选项'-L / usr / local / lib / freetds'的目录

One other note: You will probably have built FreeTDS for a single architecture, likely x86_64. By default, pymssl will be a multi-architecture build (assuming you're using the system Python 2.7.1), so even with a patched setup.py you will see a linker warning something like:

另一个注意事项:您可能已经为单个架构构建了FreeTDS,可能是x86_64。默认情况下,pymssl将是一个多架构构建(假设您使用的是系统Python 2.7.1),因此即使使用修补的setup.py,您也会看到一个链接器警告:

ld: warning: ignoring file /usr/local/lib/libsybdb.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

ld:警告:忽略文件/usr/local/lib/libsybdb.dylib,文件是为不支持的文件格式构建的,而不是被链接的体系结构(i386)

That warning just indicates that the FreeTDS libraries only have single architecture version to link against. You can avoid the warning by using ARCHFLAGS to make a x86_64-only build:

该警告只表明FreeTDS库只有单一的架构版本可以链接。您可以使用ARCHFLAGS进行仅x86_64构建来避免警告:

ARCHFLAGS="-arch x86_64" python setup.py install

ARCHFLAGS =“ - arch x86_64”python setup.py install

#2


3  

Or, try this fork, it installs without issues:

或者,尝试这个fork,它安装没有问题:

https://github.com/blackbass1988/pymssql-macos-lion

https://github.com/blackbass1988/pymssql-macos-lion

To install on OS X Mavericks, you need

要在OS X Mavericks上安装,您需要

OS X Command Line Tools

OS X命令行工具

FreeTDS

freetds的

brew install freetds

Cython

用Cython

pip install cython

and then finally you can install the pymssql-macoslion

然后最后你可以安装pymssql-macoslion

pip install git+git://github.com/blackbass1988/pymssql-macos-lion.git@master

#3


2  

Just incase anyone is reading this the following worked for me:

只是因为有人正在读这个以下为我工作:

brew install freetds
sudo pip install pymssql

#1


11  

Unfortunately, pymssql's setup.py (as of version pymssql-2.0.0b1-dev-20111019) needs a bit of help to work properly on OSX Lion. The current setup.py tries to compile/link against some pre-built Linux FreeTDS libraries, and also tries to link against librt, which doesn't exist on OSX. Additionally, it only explicitly looks for FreeTDS libraries from Fink or MacPorts, so if you've installed Homebrew (if you use if) or FreeTDS itself in a non-standard location, it may not be located by compiler/linker.

不幸的是,pymssql的setup.py(从版本pymssql-2.0.0b1-dev-20111019开始)需要一些帮助才能在OSX Lion上正常工作。当前的setup.py尝试编译/链接一些预构建的Linux FreeTDS库,并尝试链接librt,这在OSX上不存在。此外,它只显示从Fink或MacPorts中查找FreeTDS库,因此如果您在非标准位置安装了Homebrew(如果使用if)或FreeTDS本身,则编译器/链接器可能无法找到它。

I created a repaired version of setup.py here. It worked well enough for me with the Homebrew build of FreeTDS using the standard locations (/usr/local/{lib, include}), but as always YMMV. You may need to adjust setup.py further if you've installed FreeTDS in a different location. You can generally ignore the warnings from the linker about missing directories that may not exist on your system:

我在这里创建了一个修复过的setup.py版本。使用标准位置(/ usr / local / {lib,include}),FreebDS的Homebrew构建对我来说效果很好,但总是YMMV。如果您在其他位置安装了FreeTDS,则可能需要进一步调整setup.py。您通常可以忽略链接器中有关系统上可能不存在的缺少目录的警告:

ld: warning: directory not found for option '-L/usr/local/lib/freetds'

ld:警告:找不到选项'-L / usr / local / lib / freetds'的目录

One other note: You will probably have built FreeTDS for a single architecture, likely x86_64. By default, pymssl will be a multi-architecture build (assuming you're using the system Python 2.7.1), so even with a patched setup.py you will see a linker warning something like:

另一个注意事项:您可能已经为单个架构构建了FreeTDS,可能是x86_64。默认情况下,pymssl将是一个多架构构建(假设您使用的是系统Python 2.7.1),因此即使使用修补的setup.py,您也会看到一个链接器警告:

ld: warning: ignoring file /usr/local/lib/libsybdb.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

ld:警告:忽略文件/usr/local/lib/libsybdb.dylib,文件是为不支持的文件格式构建的,而不是被链接的体系结构(i386)

That warning just indicates that the FreeTDS libraries only have single architecture version to link against. You can avoid the warning by using ARCHFLAGS to make a x86_64-only build:

该警告只表明FreeTDS库只有单一的架构版本可以链接。您可以使用ARCHFLAGS进行仅x86_64构建来避免警告:

ARCHFLAGS="-arch x86_64" python setup.py install

ARCHFLAGS =“ - arch x86_64”python setup.py install

#2


3  

Or, try this fork, it installs without issues:

或者,尝试这个fork,它安装没有问题:

https://github.com/blackbass1988/pymssql-macos-lion

https://github.com/blackbass1988/pymssql-macos-lion

To install on OS X Mavericks, you need

要在OS X Mavericks上安装,您需要

OS X Command Line Tools

OS X命令行工具

FreeTDS

freetds的

brew install freetds

Cython

用Cython

pip install cython

and then finally you can install the pymssql-macoslion

然后最后你可以安装pymssql-macoslion

pip install git+git://github.com/blackbass1988/pymssql-macos-lion.git@master

#3


2  

Just incase anyone is reading this the following worked for me:

只是因为有人正在读这个以下为我工作:

brew install freetds
sudo pip install pymssql