pixeled
pixeled

Reputation: 11

ModuleNotFoundError: No module named 'mechanicalsoup' / working in command line but not in script

I just tried mechanicalsoup in python through the command line and it worked. However, if I put it in a script I get the error that the module is not found. System: Linux/Openhabian. There is a python 2.7 and a python3 version as well installed. I tried it with the python3 version of course but I get this one:

File "script.py", line 1, in <module>
import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup' 

script (though it probably doesn´t help much)

import mechanicalsoup
from urllib.request import urlopen
login_page = browser.get("https://www.myurl.com")
browser = mechanicalsoup.Browser()
login_form = login_page.soup.find("form")
login_form.find ("input", {"name": "User"})["value"] = "mylogin"
login_form.find ("input", {"name": "Pass"})["value"] = "mypass"
login_response = browser.submit(login_form, login_page.url)

Some linux rights issue or what could cause that? Thanks.

Upvotes: 1

Views: 1537

Answers (1)

Potions Seller
Potions Seller

Reputation: 1

Do python3 -m pip install mechanicalsoup (if on windows)

Upvotes: 0

Related Questions