Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

836
Visualizações
ImportError: No module named google.oauth2

I wanted to add a google.cloud.storage dependency to my project so I tried to install this dependency with

pip install --upgrade google-cloud-storage

Running my app again with dev_appserver, it shows me that my gcloud components needed to be updated. Ok so, gcloud components update

And in my src/__init__.py file, I got the code that tells gcloud in which folder to look for dependencies like this:

from google.appengine.ext import vendor

vendor.add('src/libs')

All the dependencies are installed correctly, except that I'm getting the error ImportError: No module named google.oauth2

PS: My app is using OAuth2 to secure access to the API. And it was working correctly before I do a components update, now even if I rollback code, remove the libs folder and install again dependencies, I still got the No module error, and it seems like dev_appserver is not looking for that dependency inside the libs folder !

Here's the result of gcloud --version:

Google Cloud SDK 188.0.1
app-engine-python 1.9.66
app-engine-python-extras 1.9.63
bq 2.0.28
core 2018.02.08
gsutil 4.28

And here's the Traceback:

Traceback (most recent call last):
  File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
    __import__(cumulative_path)
  File "/home/headless/Documents/Projects/meterFleet/app-backend/src/main.py", line 5, in <module>
    from src.app.user.api import UserApi
  File "/home/headless/Documents/Projects/meterFleet/app-backend/src/app/user/api.py", line 7, in <module>
    from src.googleapis.iam import getIamPolicy, addIapUser, deleteIapUser
  File "/home/headless/Documents/Projects/meterFleet/app-backend/src/googleapis/iam.py", line 5, in <module>
    from src.common.authentication import OAuth
  File "/home/headless/Documents/Projects/meterFleet/app-backend/src/common/authentication.py", line 3, in <module>
    from google.oauth2 import service_account
  File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1147, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named google.oauth2
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I've had this issue quite a bit. I uninstalled all Google packages from my local machine, deleted the lib folder in my GAE app folder, created it again then executed:

pip install -t lib google-auth google-auth-httplib2 google-api-python-client --upgrade

That should fix your problem.

over 4 years ago · Santiago Trujillo Relatório

0

EDIT: I think you never get this error if you use something like virtualenv.

The problem was coming from the dependencies being installed in both the project folder (in the src/libs folder), and in the python local libs folder (/usr/local/python2.7/dist-packages). I removed the google libraries from the python libs folder and it's now working again !

over 4 years ago · Santiago Trujillo Relatório

0

Just upgrading some python packages solved my issue:

pip install --upgrade google-auth google-auth-httplib2 google-api-python-client
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda