简体   繁体   中英

Error as follow when using 'import bs4', or 'from bs4 import BeautifulSoup'

Output Error as follow when using import bs4 , or 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'

You have corrupted your BeautifulSoup installation:

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

That is not BeautifulSoup code; see the actual bs4.element source code .

You appear to have replaced the regular element.py file in that package with one that writes an Excel worksheet (using the xlsxwriter package). You'll have to remove the whole bs4 directory and reinstall BeautifulSoup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM