googleapis / google-cloud-python

Google Cloud Client Library for Python
https://googleapis.github.io/google-cloud-python/
Apache License 2.0
4.81k stars 1.52k forks source link

ModuleNotFoundError: No module named 'google.api' #5887

Closed techiexplorer closed 6 years ago

techiexplorer commented 6 years ago

Traceback (most recent call last): File "C:/Users/farha/Desktop/VoicebotRuuh_6_langs_Modified - Copy/lol.py", line 7, in from google.cloud import speech File "C:\Python36-32\lib\site-packages\google\cloud\speech.py", line 17, in from google.cloud.speech_v1 import SpeechClient File "C:\Python36-32\lib\site-packages\google\cloud\speech_v1__init__.py", line 17, in from google.cloud.speech_v1.gapic import speech_client File "C:\Python36-32\lib\site-packages\google\cloud\speech_v1\gapic\speech_client.py", line 23, in import google.api_core.operation File "C:\Python36-32\lib\site-packages\google\api_core\operation.py", line 45, in from google.longrunning import operations_pb2 File "C:\Python36-32\lib\site-packages\google\longrunning\operations_pb2.py", line 16, in from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 ModuleNotFoundError: No module named 'google.api'

tseaver commented 6 years ago

@Farhan1998 Can you please show the output of pip freeze?

techiexplorer commented 6 years ago

Sure sir, Thank you !

This is the output of pip freeze appdirs==1.4.3 appier==1.16.29 atomicwrites==1.1.5 attrs==17.4.0 backcall==0.1.0 backports.functools-lru-cache==1.5 beautifulsoup4==4.6.3 bleach==2.1.3 bs4==0.0.1 cachetools==2.1.0 certifi==2018.8.24 cffi==1.11.5 chardet==3.0.4 ChatterBot==0.8.7 chatterbot-corpus==1.1.2 chromedriver==2.24.1 click==6.7 cmake==3.12.0 colorama==0.3.9 cycler==0.10.0 decorator==4.3.0 dogpile.cache==0.6.7 entrypoints==0.2.3 enum34==1.1.6 ez-setup==0.9 fasteners==0.14.1 fbchat==1.4.0 Flask==1.0.2 future==0.16.0 futures==3.2.0 gapic-google-longrunning==0.11.2 gcloud==0.18.3 google==2.0.1 google-api==0.1.12 google-api-core==1.3.0 google-api-python-client==1.7.4 google-apitools==0.5.23 google-auth==1.5.1 google-auth-httplib2==0.0.3 google-cloud==0.34.0 google-cloud-core==0.28.1 google-cloud-speech==0.35.0 google-cloud-translate==1.3.1 google-endpoints==4.6.1 google-endpoints-api-management==1.10.0 google-gax==0.14.1 google-search==1.0.2 google-speech==1.0.16 googleapis-common-protos==1.5.3 googletrans==2.3.0 grpc-google-longrunning-v2==0.8.1 grpcio==1.14.2 gTTS==2.0.1 gTTS-token==1.1.1 html5==0.0.9 html5lib==1.0.1 httplib2==0.11.3 idna==2.7 indic-transliteration==1.6.5 ipykernel==4.8.2 ipython==6.5.0 ipython-genutils==0.2.0 itsdangerous==0.24 jedi==0.12.1 Jinja2==2.10 jsonschema==2.6.0 jupyter-client==5.2.3 jupyter-core==4.4.0 kiwisolver==1.0.1 livelossplot==0.2.0 lxml==4.2.4 MarkupSafe==1.0 mathparse==0.1.1 matplotlib==2.2.2 mistune==0.8.3 monotonic==1.5 more-itertools==4.2.0 morfessor==2.0.4 nbconvert==5.3.1 nbformat==4.4.0 nltk==3.3 notebook==5.6.0 numpy==1.14.5 oauth2==1.9.0.post1 oauth2client==3.0.0 oauthlib==2.1.0 pandocfilters==1.4.2 parso==0.3.1 pickleshare==0.7.4 pipenv==2018.7.1 pluggy==0.6.0 ply==3.8 polyglot==16.7.4 prometheus-client==0.3.1 prompt-toolkit==1.0.15 protobuf==3.6.1 protorpc==0.12.0 py==1.5.4 pyasn1==0.4.4 pyasn1-modules==0.2.2 PyAudio==0.2.11 pycparser==2.18 pycryptodomex==3.6.6 Pygments==2.2.0 pyjwkest==1.0.9 pylru==1.1.0 pymongo==3.7.1 pyparsing==2.2.0 PySoundCard==0.5.2 PySoundFile==0.9.0.post1 pytest==3.6.3 python-appengine==1.9.15 python-dateutil==2.6.1 python-twitter==3.4.2 pytz==2018.5 pywinpty==0.5.4 PyYAML==3.13 pyzmq==17.1.0 regex==2018.8.29 requests==2.19.1 requests-oauthlib==1.0.0 rsa==3.4.2 selenium==3.14.0 semver==2.7.7 Send2Trash==1.5.0 simplegeneric==0.8.1 six==1.11.0 sounddevice==0.3.12 speech==0.5.2 SpeechRecognition==3.8.1 SQLAlchemy==1.2.11 strict-rfc3339==0.7 terminado==0.8.1 testpath==0.3.1 tornado==5.1 traitlets==4.3.2 transliterate==1.10.1 Unidecode==1.0.22 uritemplate==3.0.0 urllib3==1.23 urllib5==5.0.0 virtualenv==16.0.0 virtualenv-clone==0.3.0 wcwidth==0.1.7 web-cache==1.0.2 webencodings==0.5.1 webob==1.8.2 Werkzeug==0.14.1 wget==3.2

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Wednesday, September 5, 2018 6:35:50 PM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://github.com/Farhan1998 Can you please show the output of pip freeze?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/GoogleCloudPlatform/google-cloud-python/issues/5887#issuecomment-418723036, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AY_RUWyFsmyEnMduEwgik8wudHXzzhtPks5uX8wugaJpZM4WaSvW.

tseaver commented 6 years ago

OK, so the google-api distribution is in there. Something is broken in how the various packages are installed in to the google namespace. Can you show the output from the following:

import google
print(google.__path__)
techiexplorer commented 6 years ago

Thank you for helping me out……am in real need of a solution to this problem. Thank you !

[cid:image002.png@01D44548.C4E5E6B0]

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Wednesday, September 5, 2018 6:44:44 PM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

OK, so the google-api distribution is in there. Something is broken in how the various packages are installed in to the google namespace. Can you show the output from the following:

import google print(google.path)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/GoogleCloudPlatform/google-cloud-python/issues/5887#issuecomment-418725866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AY_RUfhI-UMyFXOBoARDfj8Uyypus2D7ks5uX85EgaJpZM4WaSvW.

tseaver commented 6 years ago

@Farhan1998 Hmm, I can't see the image referenced there: can you upload it via the web UI, rather than mail?

One thing to try is to create a fresh virtualenv and install only the bits your application actually needs (the list from pip freeze has a lot of stale packages in it). E.g.:

$ python3.6 -m venv newvenv
$ cd newvenv
$ bin/pip install google-cloud-speech
$ bin/python
>>> from google.cloud import speech
techiexplorer commented 6 years ago

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import google print(google.path) ['C:\Python36-32\lib\site-packages\google']

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Wednesday, September 5, 2018 6:57:21 PM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFarhan1998&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=Av6pVXtjFXmQA%2BsRmJV4req2dzdMfOmGJ0kX1deD%2BG0%3D&reserved=0 Hmm, I can't see the image referenced there: can you upload it via the web UI, rather than mail?

One thing to try is to create a fresh virtualenv and install only the bits your application actually needs (the list from pip freeze has a lot of stale packages in it). E.g.:

$ python3.6 -m venv newvenv $ cd newvenv $ bin/pip install google-cloud-speech $ bin/python

from google.cloud import speech

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FGoogleCloudPlatform%2Fgoogle-cloud-python%2Fissues%2F5887%23issuecomment-418729921&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=tbRaKAIt52JVRPyKH5v5N1ZAjvFA%2F6rtMPF7ORMKlNY%3D&reserved=0, or mute the threadhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAY_RUYtZNo7giRN45yymNw8SWRDmooajks5uX9E5gaJpZM4WaSvW&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=ualCusoCC8HMA4ysMQX4hAlw%2BRIdDGsUNkdSksY61UA%3D&reserved=0.

techiexplorer commented 6 years ago

Hey, it’s working in virtual environment now. But the same file again, is not working in the actual environment. Why is this happening?

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Wednesday, September 5, 2018 6:57:21 PM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFarhan1998&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=Av6pVXtjFXmQA%2BsRmJV4req2dzdMfOmGJ0kX1deD%2BG0%3D&reserved=0 Hmm, I can't see the image referenced there: can you upload it via the web UI, rather than mail?

One thing to try is to create a fresh virtualenv and install only the bits your application actually needs (the list from pip freeze has a lot of stale packages in it). E.g.:

$ python3.6 -m venv newvenv $ cd newvenv $ bin/pip install google-cloud-speech $ bin/python

from google.cloud import speech

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FGoogleCloudPlatform%2Fgoogle-cloud-python%2Fissues%2F5887%23issuecomment-418729921&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=tbRaKAIt52JVRPyKH5v5N1ZAjvFA%2F6rtMPF7ORMKlNY%3D&reserved=0, or mute the threadhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAY_RUYtZNo7giRN45yymNw8SWRDmooajks5uX9E5gaJpZM4WaSvW&data=02%7C01%7C%7C47219440ed6f407ca14108d61333503a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717508435178279&sdata=ualCusoCC8HMA4ysMQX4hAlw%2BRIdDGsUNkdSksY61UA%3D&reserved=0.

tseaver commented 6 years ago

@Farhan1998 Something in the other bits you've installed (beyond google-cloud-speech) is messing up the google namespace package.

techiexplorer commented 6 years ago

I solved it now. I copied all the files and folders from the site-packages directory of the virtual environment to the site-packages folder of the actual environment. (copied and replaced). Now everything is working fine. Thankx for the identification !

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Wednesday, September 5, 2018 7:46:21 PM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFarhan1998&data=02%7C01%7C%7C401250438122470015dc08d6133a2891%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717537834556579&sdata=mfNYG6oXs%2FHwPug%2Ba%2FtrAnDkVw%2FQL%2F%2F2wETmkoK1iW0%3D&reserved=0 Something in the other bits you've installed (beyond google-cloud-speech) is messing up the google namespace package.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FGoogleCloudPlatform%2Fgoogle-cloud-python%2Fissues%2F5887%23issuecomment-418746837&data=02%7C01%7C%7C401250438122470015dc08d6133a2891%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717537834556579&sdata=6bUOoI3Gvd83lvujK0HKGIUgwXnDyMthGssQTJrTTO0%3D&reserved=0, or mute the threadhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAY_RUUpr-QaDFTWJSWxLKsJ4JqqHz96Mks5uX9y1gaJpZM4WaSvW&data=02%7C01%7C%7C401250438122470015dc08d6133a2891%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636717537834556579&sdata=uWlfv%2BdIbIQstmt%2BhKoMLOxpAo8K%2B8tbfF%2FioMCnwSU%3D&reserved=0.

tseaver commented 6 years ago

@Farhan1998 I'm glad you worked that out!

techiexplorer commented 6 years ago

Thank you for identifying that it will work in virenv.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Tres Seaver notifications@github.com Sent: Thursday, September 6, 2018 2:12:59 AM To: GoogleCloudPlatform/google-cloud-python Cc: Iftekharuddin Mohammed; Mention Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://github.com/Farhan1998 I'm glad you worked that out!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/GoogleCloudPlatform/google-cloud-python/issues/5887#issuecomment-418874552, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AY_RUXnHH1rRuzcD8fcuFMJnw791MsKtks5uYDdTgaJpZM4WaSvW.

techiexplorer commented 6 years ago

Can you please help me out with this small issue too? https://stackoverflow.com/questions/52194281/how-to-handle-errors-raised-in-an-imported-python-package-code

From: Tres Seavermailto:notifications@github.com Sent: Thursday, September 6, 2018 2:13 AM To: GoogleCloudPlatform/google-cloud-pythonmailto:google-cloud-python@noreply.github.com Cc: Iftekharuddin Mohammedmailto:farhan_mohammed98@outlook.com; Mentionmailto:mention@noreply.github.com Subject: Re: [GoogleCloudPlatform/google-cloud-python] ModuleNotFoundError: No module named 'google.api' (#5887)

@Farhan1998https://github.com/Farhan1998 I'm glad you worked that out!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/GoogleCloudPlatform/google-cloud-python/issues/5887#issuecomment-418874552, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AY_RUXnHH1rRuzcD8fcuFMJnw791MsKtks5uYDdTgaJpZM4WaSvW.