[英]Unable to use search method from googlesearch module in google colab notebook
try:
from googlesearch import search
except ImportError:
print("No module named 'google' found")
urls = []
for j in search(str(query),tld="com",start=1, num=15, stop=15, pause=0):
print(j)
urls.append(j)
I have used the same code in my local Jupyter Notebook.我在本地 Jupyter Notebook 中使用了相同的代码。 It works.
有用。 But while executing in google colab notebook it shows me the following error.
但是在 google colab notebook 中执行时,它向我显示以下错误。
NameError Traceback (most recent call last)
<ipython-input-38-a97ca791b5a9> in <module>()
4 print("No module named 'google' found")
5 urls = []
----> 6 for j in google-search(str(query),tld="com",start=1, num=15, stop=15, pause=0):
7 print(j)
8 urls.append(j)
NameError: name 'search' is not defined
All the required modules were installed properly.所有必需的模块都已正确安装。
!pip install rake-nltk
!pip install google-search
!pip install google
!pip install urllib
!pip install beautifulsoup4
Answer is here: https://github.com/MarioVilas/googlesearch/issues/39答案在这里: https://github.com/MarioVilas/googlesearch/issues/39
The problem is related to a name conflict between packages.该问题与包之间的名称冲突有关。 If you just install
google
and not google-search
, it will work.如果您只安装
google
而不是google-search
,它将起作用。
!pip install google
If you already have them both installed, use:如果您已经安装了它们,请使用:
!pip uninstall google-search
!pip uninstall google
!pip install google
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.