【问题标题】:Mac OS X 10.6 Python 2.7 pytidylib utidylib could not find libtidyMac OS X 10.6 Python 2.7 pytidylib utidylib 找不到 libtidy
【发布时间】:2011-05-03 03:38:44
【问题描述】:

我正在回答我自己的问题,但因为我熬夜想通了,我希望能帮别人省一些痛苦。如果您在正确安装pytidylibutidylib 后收到以下任一消息,则此答案可能会有所帮助。

在 Snow Leopard 上学习 Python,我安装了 Python 2.7 的 32 位版本,以便可以使用 IDLE 解释器/编辑器。 Stackoverflow 有一个很棒的 explanation 为什么我必须这样做。

当我安装 utidylib 时,我从 'import tidy' 收到以下错误:

'OSError: Couldn't find libtidy, please make sure it is installed.'

使用 pytidylib,当我尝试 'from tidylib import tidy_document' 时出现此错误:

'OSError: Could not load libtidy using any of these names: libtidy,libtidy.so,libtidy-0.99.so.0,cygtidy-0-99-0,tidylib,libtidy.dylib,tidy.'

如果您遇到这些错误,请阅读此答案。希望对你有帮助。

【问题讨论】:

    标签: python htmltidy


    【解决方案1】:

    虽然看起来 Python 包找不到文件,但真正发生的是我为错误的架构编译了 libtidy:x86_64 而不是 i386。使用 32 位 Python 安装程序会使它们不兼容。

    对于像我这样的新手,lipo 会告诉你文件的架构:

    $ lipo -info /Library/Frameworks/Python.framework/Versions/2.7/bin/python
    Architectures in the fat file: /Library/Frameworks/Python.framework/Versions/2.7/bin/python are: ppc i386
    
    $ lipo -info /usr/lib/libtidy.dylib
    Non-fat file: /usr/lib/libtidy.dylib is architecture: x86_64

    您可能需要找到您的 libtidy.dylib 和 python 文件才能进行比较。要解决此问题,您必须为 i386 重新编译 libtidy(或链接到系统上已有的 i386 编译的 libtidy)。要为 i386 重新编译,请使用 these instructions 并进行以下修改:

    cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy
    cd tidy
    sh build/gnuauto/setup.sh
    ./configure --prefix=/usr CFLAGS="-arch i386"
    make && sudo make install
    

    这对我有用。我希望它也对你有用。

    【讨论】:

      【解决方案2】:

      我在 Linux 上遇到了类似的问题(请参阅下面的堆栈跟踪)。 pytidylib==0.2.1 在 Ubuntu 11.10 (Python 2.7) 和 Gentoo (Python 2.6) 的 virtualenv 中安装了 pip。 在Ubuntu上安装apt-get install libtidy-dev,在Gentoo上安装emerge app-text/htmltidy,解决了。

      -------------------------------------------------- -------------------- 文件“/home/andre/Progz/some_site/djcode/apps/default/tests.py”,行?,在 default.tests.__test__.doctest 失败的例子: 从 tidylib 导入 tidy_document 引发异常: 回溯(最近一次通话最后): 文件“/home/andre/Progz/some_site/lib/python2.6/site-packages/django/test/_doctest.py”,第 1267 行,在 __run compileflags, 1) 在 test.globs 文件“”,第 1 行,在 从 tidylib 导入 tidy_document 文件“/home/andre/Progz/some_site/lib/python2.6/site-packages/tidylib/__init__.py”,第 71 行,在 raise OSError("Could not load libtidy using any of these names: %s" % (",".join(LIB_NAMES))) OSError:无法使用以下任何名称加载 libtidy:libtidy、libtidy.so、libtidy-0.99.so.0、cygtidy-0-99-0、tidylib、libtidy.dylib、tidy -------------------------------------------------- --------------------

      【讨论】:

        【解决方案3】:

        我有同样的问题。我安装了tidylib,但仍然出现如下错误。

         raise OSError("Could not load libtidy using any of these names: %s" % (",".join(LIB_NAMES)))
            OSError: Could not load libtidy using any of these names: libtidy,libtidy.so,libtidy-0.99.so.0,cygtidy-0-99-0,tidylib,libtidy.dylib,tidy
        

        然后我将 /usr/bin/tidy 复制到我的项目文件夹中,它得到了解决。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-01-31
          • 1970-01-01
          • 2011-12-28
          • 2010-11-24
          • 2011-06-02
          • 1970-01-01
          • 2011-09-09
          相关资源
          最近更新 更多