简体   繁体   English

gmail API:ModuleNotFoundError:没有名为“google”的模块

[英]gmail API : ModuleNotFoundError: No module named 'google'

While running the quickstart.py of Gmail, I get the following error on macOS.在运行 Gmail 的 quickstart.py 时,我在 macOS 上收到以下错误。

Traceback (most recent call last):
  File "quickstart.py", line 4, in <module>
    from googleapiclient.discovery import build
  File "/Users/<user>/Documents/venv/bin/googleapiclient/discovery.py", line 49, in <module>
    import google.api_core.client_options
ModuleNotFoundError: No module named 'google'

These are the installed Google libraries.这些是已安装的 Google 库。

$ pip freeze | grep google
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
google-api-core==1.16.0
google-api-python-client==1.8.0
google-auth==1.12.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
google-cloud-bigquery==1.24.0
google-cloud-core==1.3.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0

From the error, the google module is not installed for Python3.从错误来看,没有为 Python3 安装 google 模块。 I'm gonna take a wild guess and say it's because your version of Python(Python2.7) has depreciated, clearly, try using python3.7(alongside pip3) hopefully it'll work.我会大胆猜测并说这是因为您的 Python(Python2.7)版本已经贬值,显然,尝试使用 python3.7(与 pip3 一起)希望它会起作用。

I think you should run我觉得你应该跑

 pip install google-cloud

If the issue persist then you have some issues with you python paths.如果问题仍然存在,那么您的python 路径存在一些问题。

You should check where the google package actually is installed:您应该检查 google 包的实际安装位​​置:

 python3 -c 'import google; print(google.__file__)'

Also you can try to install your packages in a virtualenv:您也可以尝试在 virtualenv 中安装您的软件包:

virtualenv venv
source venv/bin/activate
venv/bin/pip install your-packages
venv/bin/python -c 'import google'
deactivate
rm -fr venv/

The library google-api-core 1.16.0 is no longer supported in Python 2.7. Python 2.7 不再支持库google-api-core 1.16.0 Only versions above 3.5 are supported, as specified here :以上仅3.5版本支持,作为指定在这里

Supported Python Versions : Python >= 3.5支持的 Python 版本:Python >= 3.5

Deprecated Python Versions : Python == 2.7.弃用的 Python 版本:Python == 2.7。 Python 2.7 support will be removed on January 1, 2020. Python 2.7 支持将于 2020 年 1 月 1 日移除。

You should upgrade to a supported Python version.您应该升级到受支持的 Python 版本。

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gmail API - ModuleNotFoundError:没有名为“googleapiclient”的模块 - Python 3.7 - Gmail API - ModuleNotFoundError: No module named 'googleapiclient' - Python 3.7 ModuleNotFoundError:没有名为“google”的模块 - ModuleNotFoundError: No module named 'google' ModuleNotFoundError:没有名为“google”的模块 - ModuleNotFoundError: No module named 'google' ModuleNotFoundError: 没有名为“api”的模块 - ModuleNotFoundError: No module named 'api' ModuleNotFoundError:没有名为“google”的模块错误 - ModuleNotFoundError: No module named 'google' Error ModuleNotFoundError:在Python 3.6.7上没有名为“ google”的模块 - ModuleNotFoundError: No module named 'google' on python 3.6.7 ModuleNotFoundError:没有名为“icalendar”的模块谷歌云 - ModuleNotFoundError: No module named 'icalendar' google Cloud ModuleNotFoundError:Google Colab 上没有名为“nets”的模块 - ModuleNotFoundError: No module named 'nets' on Google Colab ModuleNotFoundError:没有名为“google_auth_oauthlib”的模块 - ModuleNotFoundError: No module named 'google_auth_oauthlib' ModuleNotFoundError:Google Colab 中没有名为“pyaudio”的模块 - ModuleNotFoundError: No module named 'pyaudio' in Google Colab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM