MarioVilas / googlesearch

Google search from Python (unofficial).
BSD 3-Clause "New" or "Revised" License
1.14k stars 390 forks source link

Cannot import name search #39

Closed nateGeorge closed 6 years ago

nateGeorge commented 7 years ago

I've installed google via pip for both python2 (system distro) and anaconda for python3. I'm using ubuntu 16.04. When I try to import anything, like search, it says

ImportError: cannot import name 'search'

That's after doing

from google import search

The same thing happens in python2 or 3.

When I import google and check the 'dir', it says: (python3)

In [84]: dir(google)
Out[84]: ['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

(python2)

In [3]: dir(google)
Out[3]: ['__doc__', '__name__', '__path__']

Any ideas what's going on? The __init__.py file looks fine where it's installed, which I found from google.__path__. But I thought for most packages, .__file__ was the way to specify the filepath to the module.

tudoanh commented 6 years ago

Maybe try again with python3-pip? I'm using pip for Python 3 and have no problems.
You should use virtualenv.

MarioVilas commented 6 years ago

I cannot reproduce the problem...

$ pip install google
Collecting google
  Downloading google-1.9.3-py2.py3-none-any.whl
Requirement already satisfied: beautifulsoup4 in /usr/lib/python2.7/dist-packages (from google)
Installing collected packages: google
Successfully installed google-1.9.3
$ python
Python 2.7.12+ (default, Sep 17 2016, 12:08:02) 
[GCC 6.2.0 20160914] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google import search
>>> 

Perhaps you have another module with the same name?

MarioVilas commented 6 years ago

Ah, I get it now, this other ticket describes the problem: https://github.com/MarioVilas/googlesearch/issues/36

MarioVilas commented 6 years ago

Changed the name of the package to "googlesearch" to avoid the name collision. Also updated the version number since this would break existing scripts.

tsunami18 commented 5 years ago

Changed the name of the package to "googlesearch" to avoid the name collision. Also updated the version number since this would break existing scripts.

how can i do this ?

HdiaSaad commented 5 years ago

Change "from google import search" To from googlesearch import search

ThePyProgrammer commented 5 years ago

ImportError: cannot import name 'search' from 'googlesearch'

MarioVilas commented 4 years ago

You'll have to give me more that that because I've no idea what you have installed or how in your computer.

On Sun, Sep 29, 2019 at 11:46 PM ThePyProgrammer notifications@github.com wrote:

ImportError: cannot import name 'search' from 'googlesearch'

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/MarioVilas/googlesearch/issues/39?email_source=notifications&email_token=AABXUU5XQIYU4UGIKNBBZ2LQMDEV5A5CNFSM4DZQVX4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73YEKI#issuecomment-536314409, or mute the thread https://github.com/notifications/unsubscribe-auth/AABXUU5ACZGCJTVZ7NEZD2DQMDEV5ANCNFSM4DZQVX4A .

-- “There's a reason we separate military and the police: one fights the enemy of the state, the other serves and protects the people. When the military becomes both, then the enemies of the state tend to become the people.”

adhv45 commented 4 years ago

AttributeError: module 'googlesearch' has no attribute 'search'

This is not working on google colab apparently.

MarioVilas commented 4 years ago

Seems to work for me... Screenshot from 2020-04-28 15-30-16

adhv45 commented 4 years ago

Thank you for your valuable time. I think it was the issue of the name collision. There were different modules I had installed for google-search. So I uninstalled all of them and then reinstalled "pip install google" only and then it worked.

MarioVilas commented 4 years ago

Glad to be of help! :)

TeoSkondras commented 7 months ago

Thank you for your valuable time. I think it was the issue of the name collision. There were different modules I had installed for google-search. So I uninstalled all of them and then reinstalled "pip install google" only and then it worked.

Had the exact same issue, changed to a new clean venv and it worked