开发者

Mac OS X 10.6 Python 2.7 pytidylib utidylib could not find libtidy

开发者 https://www.devze.com 2023-01-23 09:24 出处:网络
I am answering my own question, but beca开发者_开发知识库use 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 pr

I am answering my own question, but beca开发者_开发知识库use 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.


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


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: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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消