rrwen / search_google

A command line tool and module for Google web and image search
https://rrwen.github.io/search_google
MIT License
12 stars 1 forks source link

Command raised an exception: AttributeError: module 'search_google' has no attribute 'api' #4

Open Puncher1 opened 3 years ago

Puncher1 commented 3 years ago

Hi there

I just started using the module search-google 1.2.1 and I have a problem. First, I used the module in a python file without any other librarys except of json and search-google Everything worked. After that I put the code into a command at the library discord.py And then when I want to use search-google this error occure:

Ignoring exception in command googlesearch:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "F:\DiscordBot\PyCharm\Google\Commands\google_search.py", line 54, in googlesearch
    results = search_google.api.results(buildargs, cseargs)
AttributeError: module 'search_google' has no attribute 'api'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'search_google' has no attribute 'api'

My code: https://mystb.in/WorldcatBloggerTokyo.python

rrwen commented 2 years ago

@Puncher1 Have you tried reinstalling the package?

It looks like it did not find api.py in the package - maybe it was altered somehow or deleted.

You can also try importing api directly:

from search_google import api

results = api.results(...)