使用import bs4
或from 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'
答案 0 :(得分:1)
您的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。