Mac OS X 10.6 Python 2.7 pytidylib utidylib找不到libtidy

2024-05-10 09:07:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我在回答我自己的问题,但因为我整晚都在想这个问题,我希望能为其他人省去一些痛苦。如果在正确安装pytidylibutidylib后收到以下消息之一,则此答案可能会有所帮助。在

在雪豹上学习Python时,我安装了python2.7的32位版本,这样就可以使用空闲解释器/编辑器了。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.'

如果你发现这些错误,请阅读下面的答案。我希望这对你有帮助。在


Tags: 答案import版本消息错误编辑器stackoverflow解释器
3条回答

我在Linux上也遇到过类似的问题(见下面的stacktrace)。 在Ubuntu11.10(Python2.7)和Gentoo(Python2.6)的virtualenv中安装了pytidylib==0.2.1。 在Ubuntu上安装apt-get install libtidy-dev,在Gentoo上安装emerge app-text/htmltidy,解决了这个问题。在

                                   
File "/home/andre/Progz/some_site/djcode/apps/default/tests.py", line ?, in default.tests.__test__.doctest
Failed example:
    from tidylib import tidy_document
Exception raised:
    Traceback (most recent call last):
      File "/home/andre/Progz/some_site/lib/python2.6/site-packages/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "", line 1, in 
        from tidylib import tidy_document
      File "/home/andre/Progz/some_site/lib/python2.6/site-packages/tidylib/__init__.py", line 71, in 
        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
                                   

虽然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并进行以下修改:

^{pr2}$

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

我也遇到了同样的问题。我安装了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复制到我的项目文件夹中,它就解决了。在

相关问题 更多 >