简体   繁体   中英

Building pymssql on OS X

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

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM