Reputation: 889
Using the Gmail API in Python 3.7 to retrieve emails and I'm testing the code in both Terminal and Pycharm, yet I cannot get past line 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
I recieve the error message:
from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'
I understand there have been other similar questions regarding this same issue but none of the answers appear to help in this situation. Please see below for things I have tried and information which may help illicit a solution.
1) It appears that the packages are present and accounted for in the expected folders.
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) The project interpreters also appear to be correct:
3) Have tried reinstalling the module via PyCharm > Preferences
4) I have tried various pip commands including the following;
pip install google-api-python-client
pip install googleapiclient
pip install --upgrade google-api-python-client
Just don't understand what the issue is or how to resolve so your guidance and suggestions would be greatly appreciated.
Upvotes: 2
Views: 2423
Reputation: 786
You dont have 'google-api-python-client'. You instead have 'google-api-python-client-py3'. The former has to be available in the list of libraries:
I have installed it with:
pip install google-api-python-client
Also check if you are running the code with the same interpreter in which you installed google-api-python-client.
Upvotes: 3