pythonvisual-studio-codemechanicalsoup

Mechanicalsoup is not working after rebuild computer


I was forced to reinstall windows on my Computer. Since that, I have one problem after the other.

Right now. I have a problem with python or better mechanicalsoup. I have pythonscrips for webscrapibng which used to work completly fine. But now they do not work anymore. At the beginning I could't even use "pip install 'Packagename'" anymore. I needed to use the long way (python -m install 'Packagename'). I managed to solve this issue.

I already uninstalled and installed mechanicalsoup, python and even visual codes.

I have absolute no idea where to look and how to solve this problem by now. Did I forgot to install something important ? Has anyone an idea what's the issue here ?

That's the code i'm using right now. From my understanding there is no issue with the code. As I already mention. It use to work 3 days ago.

 import mechanicalsoup
 
 # create stateful browser
 browser = mechanicalsoup.StatefulBrowser(
 soup_config={'features': 'lxml'},
 raise_on_404=True,
 user_agent='MyBot/0.1: mysite.example.com/bot_info',
 )

 # use browser to open link
 browser.open("https://stackoverflow.com/")

 # find and follow login link
 browser.follow_link("users/login")

The Error-Message:

Traceback (most recent call last):
  File "c:\Python\Webscrapting_Test\sign_in.py", line 46, in <module>
    browser.follow_link("/users/12345678")

  File "C:\Users\dw.FROMMEDV\AppData\Local\Programs\Python\Python39\lib\site-packages\mechanicalsoup\stateful_browser.py", line 341, in follow_link
    link = self._find_link_internal(link, args, kwargs)

  File "C:\Users\dw.FROMMEDV\AppData\Local\Programs\Python\Python39\lib\site-packages\mechanicalsoup\stateful_browser.py", line 317, in _find_link_internal

return self.find_link(*args, **kwargs)

  File "C:\Users\dw.FROMMEDV\AppData\Local\Programs\Python\Python39\lib\site-packages\mechanicalsoup\stateful_browser.py", line 291, in find_link
    raise LinkNotFoundError()

mechanicalsoup.utils.LinkNotFoundError

Solution

  • According to the information you provided, the problem occurred in "mechanicalsoup\stateful_browser.py", it is recommended that you use the command "pip show mechanicalsoup" to find the module installation location, and then try to delete the module folder "mechanicalsoup", and then reinstall it to avoid The file is damaged or dependent.

    enter image description here

    enter image description here