python tidylib模块错误

标签 python import module

当我在 python 中导入 tidylib 并执行程序时,出现以下错误

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\Python27\lib\site-packages\tidylib\__init__.py", line 71, in <module>

        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

最佳答案

确保 libtidy.so 位于您的 $LD_LIBRARY_PATH 中。看起来 python 正在尝试正确导入 tidy,但是找不到 tidy 使用的库之一。

如果使用 Windows,来自 PyTidy docs :

Windows: (Use PyTidyLib version 0.2 or later!) Prebuilt HTML Tidy DLLs are available from at least two locations. The int64.org Tidy Binaries page provides binaries that were built in 2005, for both 32-bit and 64-bit Windows, against a patched version of the source. The HTML Tidy web site links to a DLL built in 2006, for 32-bit Windows only, using the vanilla source (scroll near the bottom to “Other Builds” – use the one that reads “exe/lib/dll”, not the “exe”-only version.)

Once you have a DLL (which may be named tidy.dll, libtidy.dll, or tidylib.dll), you must place it in a directory on your system path. If you are running Python from the command-line, placing the DLL in the present working directory will work, but this is unreliable otherwise (e.g. for server software).

因此,一旦您拥有该 dll,将其位置(例如 C:/myfiles/somethingelse/libtidy.dll)添加到 Windows 的 PATH,来自 mathworks :

  1. Right-click on the My Computer icon. (Under Windows XP, Vista, or Windows 7, the My Computer Icon may be located in the start menu.)
  2. Choose Properties from the context menu. (Alternatively, you can double-click on the System icon in the Control Panel)
  3. Click the Advanced tab or "Advanced system settings" on Windows Vista or Windows 7
  4. Click the Environment Variables button.
  5. Click on the variable called 'Path' and then click on Edit. Now add the target directory to the value of the variable, using a semi-colon as a separator.

For example, if you want to add the path to MATLAB/bin to your system, which if located at c:\matlab\bin, you would enter the following at the end of the Path:

;c:\matlab\bin

不要忘记分号

关于python tidylib模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19051696/

相关文章:

ruby - 命名空间和混合

python - 命名python模块有什么要求?

python - Keras - TensorBoard 不保存日志文件

python - 使用嵌入式 Python 脚本编写 Windows GUI 应用程序

django - 如何使用 django-import-export 为字段定义管理员导入格式

php - GAE - wordpress 作为 Python 应用程序内的模块

python - 如何跟踪Scrapy中已抓取的域名数量

python - Redis 和 Celery 的奇怪错误

python - 循环导入 hell

magento - 从 CSV 导入 magento 中另一个产品的追加销售产品