python-3.x 漂亮的汤不工作,当我第一次运行它

kb5ga3dv  于 2023-01-10  发布在  Python
关注(0)|答案(1)|浏览(226)
Traceback (most recent call last):
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 28, in <module>
    import cchardet as chardet_module
ModuleNotFoundError: No module named 'cchardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 33, in <module>
    import chardet as chardet_module
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/emwod/AppData/Local/Programs/Python/Python310/scrape.py", line 1, in <module>
    import bs4 as bs
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\__init__.py", line 37, in <module>
    from .builder import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\builder\__init__.py", line 9, in <module>
    from bs4.element import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\element.py", line 19, in <module>
    from bs4.formatter import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\formatter.py", line 1, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 37, in <module>
    import charset_normalizer as chardet_module
ValueError: source code string cannot contain null bytes

=== RESTART: C:/Users/emwod/AppData/Local/Programs/Python/Python310/scrape.py ==
Traceback (most recent call last):
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 28, in <module>
    import cchardet as chardet_module
ModuleNotFoundError: No module named 'cchardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 33, in <module>
    import chardet as chardet_module
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/emwod/AppData/Local/Programs/Python/Python310/scrape.py", line 1, in <module>
    from bs4 import BeautifulSoup as bs
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\__init__.py", line 37, in <module>
    from .builder import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\builder\__init__.py", line 9, in <module>
    from bs4.element import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\element.py", line 19, in <module>
    from bs4.formatter import (
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\formatter.py", line 1, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\Users\emwod\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4\dammit.py", line 37, in <module>
    import charset_normalizer as chardet_module
ValueError: source code string cannot contain null bytes

我试图启动bs4,但发生了这种情况

rjjhvcjd

rjjhvcjd1#

模块未找到错误:没有名为"cchardet"的模块
似乎不是一个严格的BeautifulSoup主题-缺少一个模块,所以如果您喜欢使用它,您应该安装它或将其放在路径中:

pip install cchardet
  • 不确定您的任务是否需要cchardet,因此问题的一些改进将是很好的。如何创建mcve

相关问题