title: ImportError: No module named _mssql
body: <p>I'm running Python 2.7.2 on OS 10.8.5  </p>
  
  <p>Trying to use pymssql, but I get the following error:</p>
  
  <pre><code>  File "time_reporting.py", line 32, in &lt;module&gt;
      import pymssql
    File "/Users/xx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.py", line 30, in &lt;module&gt;
      import _mssql, types, string, time, datetime, warnings
  ImportError: No module named _mssql
  </code></pre>
  
  <p>I've tried installing mssql with pip and brew only to be told that there's no package by that name.  The docs don't seem to cover installation.</p>
  
  <p>EDIT: </p>
  
  <p>When I try to <code>pip install pymssql</code> I get:</p>
  
  <pre><code>Downloading/unpacking pymssql
    Running setup.py egg_info for package pymssql
      setup.py: platform.system() =&gt; 'Darwin'
      setup.py: platform.architecture() =&gt; ('32bit', '')
      setup.py: platform.linux_distribution() =&gt; ('', '', '')
      setup.py: platform.libc_ver() =&gt; ('', '')
      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
      Traceback (most recent call last):
        File "&lt;string&gt;", line 16, in &lt;module&gt;
        File "/Users/xxx/.virtualenvs/oracle/build/pymssql/setup.py", line 181, in &lt;module&gt;
          if compiler.has_function('clock_gettime', libraries=['rt']):
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 808, in has_function
          objects = self.compile([fname], include_dirs=include_dirs)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 616, in compile
          depends, extra_postargs)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 412, in _setup_compile
          self.mkpath(os.path.dirname(obj))
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 931, in mkpath
          mkpath(name, mode, dry_run=self.dry_run)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dir_util.py", line 76, in mkpath
          "could not create '%s': %s" % (head, exc.args[-1]))
      distutils.errors.DistutilsFileError: could not create 'var': Permission denied
      Complete output from command python setup.py egg_info:
      setup.py: platform.system() =&gt; 'Darwin'
  
  setup.py: platform.architecture() =&gt; ('32bit', '')
  
  setup.py: platform.linux_distribution() =&gt; ('', '', '')
  
  setup.py: platform.libc_ver() =&gt; ('', '')
  
  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
  
  Traceback (most recent call last):
  
    File "&lt;string&gt;", line 16, in &lt;module&gt;
  
    File "/Users/xxx/.virtualenvs/oracle/build/pymssql/setup.py", line 181, in &lt;module&gt;
  
      if compiler.has_function('clock_gettime', libraries=['rt']):
  
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 808, in has_function
  
      objects = self.compile([fname], include_dirs=include_dirs)
  
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 616, in compile
  
      depends, extra_postargs)
  
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 412, in _setup_compile
  
      self.mkpath(os.path.dirname(obj))
  
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 931, in mkpath
  
      mkpath(name, mode, dry_run=self.dry_run)
  
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dir_util.py", line 76, in mkpath
  
      "could not create '%s': %s" % (head, exc.args[-1]))
  
  distutils.errors.DistutilsFileError: could not create 'var': Permission denied
  </code></pre>
  
  <p>So I try <code>brew install freetds</code> and I get:</p>
  
  <p><code>Warning: freetds-0.91 already installed, it's just not linked</code> </p>
  
  <p>which at least makes sense, but I don't know how to fix it. </p>
  
  <p>EDIT:  I've linked it, so <code>brew install freetds</code> gives the message that it's already installed, but <code>pip install pymssql</code> still gives the above error message.</p>
  
  <p>EDIT:  </p>
  
  <pre><code>export CFLAGS=-Qunused-arguments
  export CPPFLAGS=-Qunused-arguments
  
  pip uninstall MySQL-python
  brew uninstall mysql
  brew install mysql --universal
  pip install MySQL-python
  </code></pre>
  
  <p>Which now gives me the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "time_reporting.py", line 34, in &lt;module&gt;
      import pymssql
  ImportError: dlopen(/Users/xxx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.so, 2): Symbol not found: _dbversion
    Referenced from: /Users/xxx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.so
    Expected in: flat namespace
   in /Users/xxx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.so
  </code></pre>
  
  <p>Which I've had and fixed before but I don't remember what I did.</p>
  
  <p>EDIT:</p>
  
  <p>OK, I've re-installed the 32-bit oracle and forced Python to run the 32-bit version (I think.  I really have no idea what that last sentence means, but I think I've followed instructions correctly).</p>
  
  <p>At any rate, here's my error message now:</p>
  
  <pre><code>  File "time_reporting.py", line 31, in &lt;module&gt;
      import cx_Oracle
    File "build/bdist.macosx-10.8-x86_64/egg/cx_Oracle.py", line 7, in &lt;module&gt;
    File "build/bdist.macosx-10.8-x86_64/egg/cx_Oracle.py", line 6, in __bootstrap__
  ImportError: dlopen(/Users/xxx/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.8-x86_64.egg-tmp/cx_Oracle.so, 2): no suitable image found.  Did find:
      /Users/xxx/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.8-x86_64.egg-tmp/cx_Oracle.so: mach-o, but wrong architecture
  </code></pre>