why do I get error on the first module? for example in the following code no matter what I import first, I just get importError for the first module when I run it on CMD, for example if I put "requests" module at the top I get importError: No module named requests, and it happens for others if I put them as the first module. I pass it to CMD I get importError for the first module.
FYI: I installed all modules via pip install, and they worked well till yesterday. I haven't changed anything on my system up until now!
code:
#! python3
# lucky.py - opens several google search results
import bs4, sys, webbrowser, requests
print('Googling...') # display it while downloading the google page
res = requests.get('https://google.com/search?q=' + ' '.join(sys.argv[1:]))
res.raise_for_status()
# Retrieve top search result links.
soup = bs4.BeautifulSoup(res.text, features="html.parser")
# Open a browser tab for each result.
linkElems = soup.select('.r a')
numOpen = min(5, len(linkElems))
for i in range(numOpen):
webbrowser.open('https://google.com' + linkElems[i].get('href'))
and this is the command and the error that I get on CMD:
C:\Windows\system32>lucky.py newyork
Traceback (most recent call last):
File "D:\MyPythonScripts\lucky.py", line 3, in <module>
import bs4, sys, webbrowser, requests
ImportError: No module named bs4
Thanks.