1

firsttime poster on stack overflow. I wrote the following code:

import requests
from bs4 import BeautifulSoup

request=requests.get('https://www.bever.nl/p/msr-pocket-rocket-2-brander-MECCC70060.html?colour=658')
soup = BeautifulSoup(request.text, 'html.parser')

product_data = soup.find_all(class_='as-a-text as-a-text--s glossary-highlight')

product_weight = 0
for x in range(len(product_data)):
    if 'Gewicht (g)' in product_data[x]:
        product_weight = int(product_data[x+1].text)

print(product_weight)

But the console throws the following error:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\Joop_\AppData\Local\Programs\Python\Python310\Projects\Bever script.py", line 1, in <module>
    import requests
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\__init__.py", line 45, in <module>
    from .exceptions import RequestsDependencyWarning
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\exceptions.py", line 9, in <module>
    from .compat import JSONDecodeError as CompatJSONDecodeError
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\compat.py", line 13, in <module>
    import charset_normalizer as chardet
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\__init__.py", line 24, in <module>
    from .api import from_bytes, from_fp, from_path, normalize
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\api.py", line 10, in <module>
    from .cd import (
  File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\cd.py", line 7, in <module>
    from .assets import FREQUENCIES
ImportError: cannot import name 'FREQUENCIES' from 'charset_normalizer.assets' (unknown location)

I'm pretty new to Python and I have no idea what's causing this problem. I have tried to reimport the modules, and I've even uninstalled python and reinstalled it. I have also tried to repair python using the installer.

Joophaha
  • 11
  • 1

1 Answers1

0

It seems like this issue.

Check your pythonPath and recreat pipenv.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13