即使在 pip 中也找不到模块

时间:2021-06-07 10:39:36

标签: python modulenotfounderror

我使用命令 pip install google 安装了一个模块。它可以运行文件,但是当我尝试使用此模块运行文件时,它会出错。

The image of error

我的代码:-

from google import search

ip=raw_input("What would you like to search for? ")

for url in search(ip, stop=20):
     print(url)

我已经安装了谷歌。

enter image description here

我在这里做错了什么?

注意事项:-

  1. 我只安装了 1 个 python (Python 3.9.5)
  2. 即使使用命令 python -m pip install google 它也不起作用。 Image- Module not found

谢谢!

2 个答案:

答案 0 :(得分:1)

如果您安装了 1 个以上的 python,则 pip 可能会在不同的 python 中安装 google。要确保它确实为您正在使用的 python 安装模块,请执行以下操作:

python -m pip install google

然后再次尝试运行您的代码。如果您想了解有关 installing 的更多信息,您可以阅读Installing Python Modules

答案 1 :(得分:0)

是的,我找到了自己的解决方案。感谢@user42 提供链接。我使用了这个命令并且它起作用了。

pip install --upgrade google-api-python-client

我已经给出了答案,因为它可以帮助正在或将要面临相同问题的人。