5 ms·
Traceback (most recent call last): File "0a51cb60301828feeaf66cbc908297ae.py", line 9, in <module> for j in search(query, tld="co.in", num=10, sto
by happy-go-lucky 9y ago
Traceback (most recent call last):
File "0a51cb60301828feeaf66cbc908297ae.py", line 9, in <module>
for j in search(query, tld="co.in", num=10, stop=1, pause=2):
NameError: name 'search' is not defined
Edit: Maybe imports don't work.
- mkalygin 9y agoI'm not the author of the package, but it works for me. How do you import the package? It should be `from google import search`.
- happy-go-lucky 9y agoGo to the link. Click Run on IDE, then click Run at the bottom of the new tab, see if you don't get the error :) The code snippets may run on your device successfully, but I was testing the UI at the site.
- jimnotgym 9y agoYou are right, it doesn't work on the site IDE. Looks like the google module has not been installed in their environment?
- happy-go-lucky 9y agoFor security reasons, some people keep external source from running.
- justinsaccount 9y agoYou missed the Output: No module named 'google' found below. If they cut out this nonsense: try: from google import search except ImportError: print("No module named 'google' found") and just used from google import search One would have gotten a sane error message: Traceback (most recent call last): File "00359ada2bfcd6dbabd1fa0207e683b8.py", line 1, in <module> from google import search ImportError: No module named google catching ImportError when you have no fallback is a pointless thing to do.
- happy-go-lucky 9y ago> You missed the Output: No module named 'google' found I didn't miss that. I knew it wouldn't work. Just gave it a try :)
- ehsankia 9y agoFirst thing that jumped at me when I was reading the code. Why would you wrap an import in a try catch unless you want to import something else when the first one fails. And if you don't, you should exit ones the import fails rather than let it continue and hit inevitable failure.
- philipov 9y agoMaybe it was written by programmers trained on compiled languages with no interpreter to automatically catch all exceptions and print a traceback for you, so now they're cargo culting onto "Every exception must get caught to avoid undefined behavior."