gpt4 book ai didi

python - 使用 'import bs4' 或 'from bs4 import BeautifulSoup' 时出现以下错误

转载 作者:太空宇宙 更新时间:2023-11-03 18:08:10 24 4
gpt4 key购买 nike

使用import bs4from bs4 import BeautifulSoup时输出错误如下

'''Here there is output of another py file I have removed'''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python\Anaconda2\lib\site-packages\bs4\__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "D:\Python\Anaconda2\lib\site-packages\bs4\builder\__init__.py", line 4, in <module>
from bs4.element import (
File "D:\Python\Anaconda2\lib\site-packages\bs4\element.py", line 160, in <module>
workbook.close()
File "D:\Python\Anaconda2\lib\site-packages\xlsxwriter\workbook.py", line 240, in close
self._store_workbook()
File "D:\Python\Anaconda2\lib\site-packages\xlsxwriter\workbook.py", line 448, in _store_workbook
allowZip64=self.allow_zip64)
File "D:\Python\Anaconda2\lib\zipfile.py", line 756, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 22] invalid mode ('wb') or filename: 'D:\\Data\\\xe6\x95\xb00\xe6\x8d\xae\xe6\xba\x90.xlsx'

最佳答案

您已经损坏了 BeautifulSoup 安装:

  File "D:\Python\Anaconda2\lib\site-packages\bs4\element.py", line 160, in <module> 
workbook.close()

不是 BeautifulSoup 代码;请参阅actual bs4.element source code .

您似乎已将该包中的常规 element.py 文件替换为编写 Excel 工作表的文件(使用 xlsxwriter 包)。您必须删除整个 bs4 目录并重新安装 BeautifulSoup。

关于python - 使用 'import bs4' 或 'from bs4 import BeautifulSoup' 时出现以下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26468387/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com