尝试在Mac OS X 10.6.6上构建任何版本的pymssql。版本1.0.2(稳定)和1.9.909(主干)都构建和安装,但在导入时返回以下错误。有没有人在这个项目上取得成功? (注意我在此期间使用 pyodbc ,但是如果可能的话,想要消除ODBC层)
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymssql
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_mssql.pxd", line 10, in init pymssql (pymssql.c:8444)
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymssql-1.9.909_dev-py2.6-macosx-10.6-intel.egg/_mssql.so, 2): **Symbol not found: _dbadata**
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymssql-1.9.909_dev-py2.6-macosx-10.6-intel.egg/_mssql.so
**Expected in: flat namespace**
in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymssql-1.9.909_dev-py2.6-macosx-10.6-intel.egg/_mssql.so
答案 0 :(得分:1)
fab(fabric)脚本我写的是为了做到这一点
import os
from fabric.api import local
def prep_dev_env():
os.chdir('/tmp/')
local('cvs -d:pserver:freetds.cvs.sourceforge.net:/cvsroot/freetds login')
local('cvs -z3 -d:pserver:freetds.cvs.sourceforge.net:/cvsroot/freetds checkout -P freetds')
os.chdir('/tmp/freetds/')
local('sudo ./autogen.sh --with-tdsver=7.0')
local('sudo make')
local('sudo make install')
os.chdir('/tmp/')
#assumes macports is installed
local('sudo port install mercurial')
local('hg clone https://code.google.com/p/pymssql/')
os.chdir('/tmp/pymssql/')
local('python setup.py config')
local('python setup.py build')
local('python setup.py install')
return
答案 1 :(得分:1)
使用tdsver 7.2,请参阅here
在我的虚拟环境中:
pip install cython >> ok
vim `locate Formula/freetds.rb`
#:s:7.1:8.0:g # Change version 7.1 to 8.0...
#:wq
cd /tmp
wget http://pypi.python.org/packages/source/p/pymssql/pymssql-1.0.2.tar.gz#md5=04dc4aa591acacbc8f183daeea21b690
tar -xzvf pymssql-1.0.2.tar.gz
cd pymssql-1.0.2
python setup.py config
python setup.py build
sudo python setup.py install
最后,成功!