Building pymssql on OS X

◇◆丶佛笑我妖孽 提交于 2019-12-22 01:43:16

问题


Attempting to build any version of pymssql on Mac OS X 10.6.6. Both versions 1.0.2 (stable) and 1.9.909 (trunk) build and install, but return the following error on import. Has anyone had success with this project? (note I am using pyodbc in the meantime, but would like to eliminate the ODBC layer if possible)

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

回答1:


fab (fabric) script I wrote to do this

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



回答2:


Got this to work with tdsver 7.2, see here

In the context of my virtual environment:

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

Finally, success!



来源:https://stackoverflow.com/questions/6398292/building-pymssql-on-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!