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

标签 python htmltidy

我正在回答我自己的问题,但因为我彻夜未眠地解决这个问题,我希望能为其他人减轻一些痛苦。如果正确安装后收到以下任一消息 pytidylibutidylib ,这个答案可能有帮助。

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

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

操作系统错误:找不到 libtidy,请确保已安装它。”

使用 pytidylib,当我尝试“from tidylib import tidy_document”时遇到此错误:

'OSError:无法使用以下任何名称加载 libtidy:libtidy、libtidy.so、libtidy-0.99.so.0、cygtidy-0-99-0、tidylib、libtidy.dylib、tidy。'

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

最佳答案

我在 Linux 上遇到了类似的问题(请参阅下面的堆栈跟踪)。 在 Ubuntu 11.10 (Python 2.7) 和 Gentoo (Python 2.6) 上的 virtualenv 中使用 pip 安装了 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 - Mac OS X 10.6 Python 2.7 pytidylib utidylib 找不到 libtidy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4064611/

相关文章:

python - 如何在 BS4 中搜索包含给定字符串的标签?

Python pandas correlation corr() 类型错误 : Could not compare ['pearson' ] with block values

python - jupyter notebook 不断重新连接

python - 从迭代器创建 `input_fn`

angularjs - 如何整理 Angular html?

javascript - Google-App-Engine channel API : Server doesn't send message to client

c# - 将 html 字符串拆分为 N 部分

c - Libtidy HTML 到 XHTML 并保存在字符串 C

xslt - 删除重复的 xml header

html - Notepad++ HTML 整洁