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

发布于 2024-09-30 04:26:47 字数 918 浏览 2 评论 0原文

我正在回答我自己的问题,但因为我整夜都在思考这个问题,所以我希望能给其他人带来一些痛苦。如果您在正确安装 pytidylib 后收到以下消息之一,或者utidylib,这个答案可能会有所帮助。

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

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

OSError: 无法找到 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.'

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

I am answering my own question, but because I stayed up all night figuring it out, I will hopefully save others some pain. If you are getting either of the following messages after properly installing pytidylib or utidylib, this answer may help.

Learning Python on Snow Leopard, I had installed the 32-bit version of Python 2.7 so that I could use the IDLE interpreter/editor. Stackoverflow has a great explanation why I had to do this.

When I installed utidylib, I got the following error from 'import tidy':

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

With pytidylib, I got this error when I tried '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.'

If you are getting these errors, please read this answer. I hope it helps you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深海不蓝 2024-10-07 04:26:47

我在 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
----------------------------------------------------------------------

I had a similar issue (see stacktrace below) on Linux.
With pytidylib==0.2.1 installed with pip in a virtualenv on both Ubuntu 11.10 (Python 2.7) and Gentoo (Python 2.6).
Installing apt-get install libtidy-dev on Ubuntu and emerge app-text/htmltidy on Gentoo, solved it.

----------------------------------------------------------------------
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
----------------------------------------------------------------------
椒妓 2024-10-07 04:26:47

虽然看起来 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,请使用这些说明以下修改:

cvs -z3 -d:pserver:[email protected]:/cvsroot/tidy co -P tidy
cd tidy
sh build/gnuauto/setup.sh
./configure --prefix=/usr CFLAGS="-arch i386"
make && sudo make install

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

Although it looked like the Python packages could not find the files, what was really happening was that I compiled libtidy for the wrong architecture: x86_64 instead of i386. Using the 32-bit Python installer made them incompatible.

For neophytes like me, lipo will tell you the architecture of your files:

$ 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

You may have to locate your libtidy.dylib and python files to compare. To fix the problem, you have to re-compile libtidy for i386 (or link to an i386-compiled libtidy already on your system). To re-compile for i386, use these instructions with the following modification:

cvs -z3 -d:pserver:[email protected]:/cvsroot/tidy co -P tidy
cd tidy
sh build/gnuauto/setup.sh
./configure --prefix=/usr CFLAGS="-arch i386"
make && sudo make install

This worked for me. I hope it also works for you.

找回味觉 2024-10-07 04:26:47

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

I had a same issue.I installed tidylib,but still come out error as followed.

 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

then I copy /usr/bin/tidy to my project folder ,and it got solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文