Gmail API-ModuleNotFoundError:没有名为'googleapiclient'的模块-Python 3.7

问题描述 投票:0回答:1

使用Python 3.7中的Gmail API检索电子邮件,并且我正在终端和Pycharm中测试代码,但我无法越过第7行:

#!/usr/bin/env python3

import pickle
import os.path
import email
import base64
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

我收到错误消息:

  from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'

我知道关于同一问题,还有其他类似的问题,但是在这种情况下,没有任何答案可能会有所帮助。请参阅以下我尝试过的方法以及可能有助于解决问题的信息。

1)似乎在预期的文件夹中存在并占了包。

user /⁨PycharmProjects⁩/ projectname /venv⁩/⁨lib⁩/python3.7⁩/ site-packages

__pycache__
apiclient
cachetools
cachetools-4.1.0.dist-info
dateutil
easy-install.pth
easy_install.py
google
google_api_python_client_py3-1.2-py3.7.egg-info
google_auth-1.14.2-py3.8-nspkg.pth
google_auth-1.14.2.dist-info
google_auth_httplib2-0.0.3.dist-info
google_auth_httplib2.py
httplib2
httplib2-0.17.3.dist-info
numpy
numpy-1.18.4.dist-info
oauth2client
pandas
pandas-1.0.3.dist-info
pip-10.0.1-py3.7.egg
pkg_resources
pyasn1
pyasn1-0.4.8.dist-info
pyasn1_modules
pyasn1_modules-0.2.8.dist-info
python_dateutil-2.8.1.dist-info
pytz
pytz-2020.1.dist-info
rsa
rsa-4.0.dist-info
setuptools
setuptools-46.1.3.dist-info
setuptools.pth
six-1.14.0.dist-info
six.py
uritemplate

2)项目解释器似乎也是正确的:

enter image description here

3)尝试通过PyCharm重新安装模块>首选项enter image description here

4)我尝试了包括以下内容在内的各种pip命令;

pip install google-api-python-client

pip install googleapiclient

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

只是不了解问题是什么或如何解决,因此您的指导和建议将不胜感激。

python python-3.x pip pycharm google-api-client
1个回答
1
投票

您没有“ google-api-python-client”。相反,您拥有“ google-api-python-client-py3”。前者必须在库列表中可用:

enter image description here

我已经安装了:pip install google-api-python-client

还请检查您是否正在使用与安装google-api-python-client相同的解释器运行代码。

© www.soinside.com 2019 - 2024. All rights reserved.