使用 Python 的 pd.read_html() 函数在 Spyder 环境中爬取数据时,如果将项目打包成 EXE 文件后运行,可能会遇到 'ImportError: html5lib not found' 的错误。这是因为打包过程中没有将 html5lib 模块正确包含进去。

解决方法是在 setup.py 文件中添加 html5lib 模块的依赖项。以下是一个示例:

from setuptools import setup

setup(
    ...
    install_requires=['html5lib'],
    ...
)

添加完依赖后,重新打包 EXE 文件即可解决问题。

Python Spyder 中使用 pd.read_html() 爬取数据打包成 EXE 后报错 'ImportError: html5lib not found' 的解决方法

原文地址: https://www.cveoy.top/t/topic/k43N 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录