Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import name search #39

Closed
nateGeorge opened this issue Sep 4, 2017 · 13 comments
Closed

Cannot import name search #39

nateGeorge opened this issue Sep 4, 2017 · 13 comments

Comments

@nateGeorge
Copy link

nateGeorge commented Sep 4, 2017

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
Copy link

tudoanh commented Dec 9, 2017

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

@MarioVilas
Copy link
Owner

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
Copy link
Owner

MarioVilas commented Jan 10, 2018

Ah, I get it now, this other ticket describes the problem: #36

@MarioVilas
Copy link
Owner

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
Copy link

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
Copy link

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

@ThePyProgrammer
Copy link

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

@MarioVilas
Copy link
Owner

MarioVilas commented Oct 31, 2019 via email

@adhv45
Copy link

adhv45 commented Apr 28, 2020

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

This is not working on google colab apparently.

@MarioVilas
Copy link
Owner

MarioVilas commented Apr 28, 2020

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

@adhv45
Copy link

adhv45 commented Apr 28, 2020

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
Copy link
Owner

Glad to be of help! :)

Repository owner deleted a comment from Ash4059 Sep 8, 2020
@TeoSkondras
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants