6

OS 10.8.5でPython 2.7.2を実行しています

pymssql を使用しようとしていますが、次のエラーが発生します。

  File "time_reporting.py", line 32, in <module>
    import pymssql
  File "/Users/xx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.py", line 30, in <module>
    import _mssql, types, string, time, datetime, warnings
ImportError: No module named _mssql

mssql を pip と brew でインストールしようとしましたが、その名前のパッケージがないと言われました。ドキュメントはインストールをカバーしていないようです。

編集:

私が取得しようとするpip install pymssqlと:

Downloading/unpacking pymssql
  Running setup.py egg_info for package pymssql
    setup.py: platform.system() => 'Darwin'
    setup.py: platform.architecture() => ('32bit', '')
    setup.py: platform.linux_distribution() => ('', '', '')
    setup.py: platform.libc_ver() => ('', '')
    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 "<string>", line 16, in <module>
      File "/Users/xxx/.virtualenvs/oracle/build/pymssql/setup.py", line 181, in <module>
        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() => 'Darwin'

setup.py: platform.architecture() => ('32bit', '')

setup.py: platform.linux_distribution() => ('', '', '')

setup.py: platform.libc_ver() => ('', '')

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 "<string>", line 16, in <module>

  File "/Users/xxx/.virtualenvs/oracle/build/pymssql/setup.py", line 181, in <module>

    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

だから私は試しbrew install freetdsて、私は得る:

Warning: freetds-0.91 already installed, it's just not linked

これは少なくとも理にかなっていますが、修正方法がわかりません。

編集:リンクしたので、brew install freetdsすでにインストールされているというメッセージが表示されますが、pip install pymssqlそれでも上記のエラーメッセージが表示されます。

編集:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

pip uninstall MySQL-python
brew uninstall mysql
brew install mysql --universal
pip install MySQL-python

エラーが表示されます:

Traceback (most recent call last):
  File "time_reporting.py", line 34, in <module>
    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

以前に修正したことがありますが、何をしたか覚えていません。

編集:

OK、32ビットのオラクルを再インストールし、Pythonに32ビットバージョンを強制的に実行させました(最後の文が何を意味するのか本当にわかりませんが、指示には正しく従ったと思います)。

とにかく、ここに私のエラーメッセージがあります:

  File "time_reporting.py", line 31, in <module>
    import cx_Oracle
  File "build/bdist.macosx-10.8-x86_64/egg/cx_Oracle.py", line 7, in <module>
  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
4

2 に答える 2

2

これらをルートとして実行しました:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

それからしなければならなかった:

pip uninstall MySQL-python
brew uninstall mysql
brew install mysql --universal
pip install MySQL-python

成功するかどうかはわかりませんが、少なくとも新しいエラー メッセージです。

于 2014-08-21T17:59:05.517 に答える