googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.71k stars 2.4k forks source link

ModuleNotFoundError: No module named 'google.api_core' #1393

Closed Daniel-Chin closed 3 years ago

Daniel-Chin commented 3 years ago

Environment details

Steps to reproduce

  1. Download release 2.7.0. python setup.py build. python setup.py install.
  2. Run python. import apiclient raises

    ModuleNotFoundError: No module named 'google.api_core'

Guess what

If I move ...\anaconda\lib\site-packages\google_api_core-1.28.0-py3.6.egg\google\api_core to ...\anaconda\lib\site-packages\google, then import apiclient works.

Is this a package resolution problem?

parthea commented 3 years ago

Hi @Daniel-Chin ,

Thanks for reporting this issue. I'm glad that you found a workaround. I wasn't able to re-create the issue in my environment so I'll try an environment similar to yours. Can you please also share the output of pip freeze?

Daniel-Chin commented 3 years ago

Hi @Daniel-Chin ,

Thanks for reporting this issue. I'm glad that you found a workaround. I wasn't able to re-create the issue in my environment so I'll try an environment similar to yours. Can you please also share the output of pip freeze?

pip freeze output

alabaster==0.7.10 anaconda-client==1.6.9 anaconda-navigator==1.7.0 anaconda-project==0.8.2 asn1crypto==0.24.0 astroid==1.6.1 astropy==2.0.3 attrs==17.4.0 audioread==2.1.8 autopep8 @ file:///tmp/build/80754af9/autopep8_1596578164842/work Babel==2.5.3 backports.shutil-get-terminal-size==1.0.0 beautifulsoup4==4.6.0 bitarray==0.8.1 bkcharts==0.2 blaze==0.11.3 bleach==2.1.2 bokeh==0.12.13 boto==2.48.0 boto3==1.11.10 botocore==1.14.10 Bottleneck==1.2.1 cachetools==4.2.2 certifi==2020.12.5 cffi==1.11.4 chardet==3.0.4 click==6.7 clipboard==0.0.4 cloudpickle==0.5.2 clyent==1.2.2 cocos2d==0.6.7 colorama==0.3.9 comtypes==1.1.4 conda==4.4.10 conda-build==3.4.1 conda-verify==2.0.0 contextlib2==0.5.5 crepe==0.0.11 crypto==1.4.1 cryptography==2.7 cycler==0.10.0 Cython==0.27.3 cytoolz==0.9.0 dask==0.16.1 datashape==0.5.4 decorator==4.2.1 distributed==1.20.2 docutils==0.14 entrypoints==0.2.3 et-xmlfile==1.0.1 fastcache==1.0.2 filelock==2.0.13 Flask==0.12.2 Flask-Cors==3.0.3 future==0.17.1 gast==0.3.3 gevent==1.2.2 glob2==0.6 greenlet==0.4.12 h5py==2.7.1 heapdict==1.0.0 hmmlearn==0.2.4 html5lib==1.0.1 httplib2==0.19.1 idna==2.6 imageio @ file:///tmp/build/80754af9/imageio_1594161405741/work imagesize==0.7.1 ipython==6.2.1 ipython-genutils==0.2.0 ipywidgets==7.1.1 iso8601==0.1.12 isort==4.2.15 itsdangerous==0.24 jdcal==1.3 jedi==0.11.1 Jinja2==2.10 jmespath==0.9.4 joblib==0.14.1 jsonschema==2.6.0 jupyter==1.0.0 jupyter-client==5.2.2 jupyter-console==5.2.0 jupyter-core==4.4.0 jupyterlab==0.31.4 jupyterlab-launcher==0.10.2 keyboard==0.13.4 kiwisolver==1.2.0 lazy-object-proxy==1.3.1 llvmlite==0.21.0 locket==0.2.0 lxml==4.1.1 markdown2==2.3.10 MarkupSafe==1.0 matplotlib==3.2.1 mccabe==0.6.1 menuinst==1.4.11 mido==1.2.9 mistune==0.8.3 mlxtend==0.17.2 mouse==0.7.0 mpmath==1.0.0 msgpack-python==0.5.1 multipledispatch==0.4.9 Naked==0.1.31 navigator-updater==0.1.0 nbconvert==5.3.1 nbformat==4.4.0 networkx==2.1 nltk==3.2.5 nose==1.3.7 notebook==5.4.0 numba==0.36.2 numexpr==2.6.4 numpy==1.19.4 numpydoc==0.7.0 oauth2client==4.1.3 odo==0.5.1 olefile==0.45.1 opencv-python==4.4.0.46 openpyxl==2.4.10 osc4py3==1.0.8 packaging==16.8 pandas==1.1.5 pandocfilters==1.4.2 parso==0.1.1 partd==0.3.8 path.py==10.5 pathlib2==2.3.0 patsy==0.5.0 pdfrw==0.4 pep8==1.7.1 pickleshare==0.7.4 Pillow==5.0.0 pkginfo==1.4.1 pluggy==0.6.0 ply==3.10 pretty-midi==0.2.8 prompt-toolkit==1.0.15 protobuf==3.17.1 psutil==5.4.3 py==1.5.2 pyasn1==0.4.7 pyasn1-modules==0.2.8 PyAudio==0.2.11 pycodestyle==2.6.0 pycosat==0.6.3 pycparser==2.18 pycrypto==2.6.1 pycurl==7.43.0.1 pyflakes==1.6.0 pygame==2.0.1 pyglet==1.4.3 Pygments==2.2.0 pylint==1.8.2 PyNaCl==1.3.0 pyodbc==4.0.22 pyOpenSSL==17.5.0 pyparsing==2.4.7 pyperclip==1.8.0 pyserial==3.4 PySocks==1.6.7 pytest==3.3.2 python-dateutil==2.8.1 python-rtmidi==1.3.1 pytz==2017.3 PyWavelets==0.5.2 pywin32==222 pywinpty==0.5 PyYAML==3.13 pyzmq==16.0.3 qrcode==6.1 QtAwesome==0.4.4 qtconsole==4.3.1 QtPy==1.3.1 regex==2020.1.8 requests==2.18.4 resampy==0.2.2 rope==0.10.7 rsa==4.0 ruamel-yaml==0.15.35 s3transfer==0.3.2 sacremoses==0.0.38 scikit-image==0.13.1 scikit-learn==0.23.1 scipy==1.4.1 seaborn==0.8.1 Send2Trash==1.4.2 sentencepiece==0.1.85 shellescape==3.4.1 simpleaudio==1.0.2 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.16.0 snowballstemmer==1.2.1 sortedcollections==0.5.3 sortedcontainers==1.5.9 Sphinx==1.6.6 sphinxcontrib-websupport==1.0.1 spyder==3.2.6 SQLAlchemy==1.2.1 statsmodels==0.12.2 sympy==1.1.1 tables==3.4.2 tblib==1.3.2 tensorflow-estimator==2.4.0 terminado==0.8.1 testpath==0.3.1 threadpoolctl==2.1.0 tokenizers==0.0.11 toml @ file:///tmp/build/80754af9/toml_1592853716807/work toolz==0.9.0 torch==1.4.0 torchvision==0.5.0 tornado==4.5.3 tqdm==4.42.1 traitlets==4.3.2 transformers==2.4.1 typing==3.6.2 unicodecsv==0.14.1 uritemplate==3.0.1 urllib3==1.22 wcwidth==0.1.7 webencodings==0.5.1 Werkzeug==0.14.1 widgetsnbextension==3.1.0 win-inet-pton==1.0.1 win-unicode-console==0.5 wincertstore==0.2 wrapt==1.10.11 xlrd==1.1.0 XlsxWriter==1.0.2 xlwings==0.11.5 xlwt==1.3.0 zict==0.1.3

Daniel-Chin commented 3 years ago

Hi @Daniel-Chin ,

Thanks for reporting this issue. I'm glad that you found a workaround. I wasn't able to re-create the issue in my environment so I'll try an environment similar to yours. Can you please also share the output of pip freeze?

And, yes, the workaround worked for me and I've been using the API for a day now haha

parthea commented 3 years ago

I'm going to close this issue as I'm not able to reproduce it locally but please feel free to re-open it.

hapesurya commented 2 years ago

Dear All,

The same problem happens to me. I use a virtual environment.

When I run sample python code from YouTube.channel.list there some error:

File "/home/hape/Documents/Script_Python/VENV/youtube_dl/venv/lib/python3.8/site-packages/google_api_python_client-2.42.0-py3.8.egg/googleapiclient/discovery.py", line 44, in import google.api_core.client_options ModuleNotFoundError: No module named 'google.api_core'

Below is my pip list.

Package Version


cachetools 5.0.0
certifi 2021.10.8 charset-normalizer 2.0.12
google-api-core 2.7.1
google-api-python-client 2.42.0
google-auth 2.6.2
google-auth-httplib2 0.1.0
google-auth-oauthlib 0.5.1
googleapis-common-protos 1.56.0
httplib2 0.20.4
idna 3.3
oauthlib 3.2.0
pip 20.0.2
pkg-resources 0.0.0
protobuf 4.0.0rc2
pyasn1 0.4.8
pyasn1-modules 0.2.8
pyparsing 3.0.7
requests 2.27.1
requests-oauthlib 1.3.1
rsa 4.8
setuptools 44.0.0
six 1.16.0
uritemplate 4.1.1
urllib3 1.26.9
youtube-dl 2021.12.17

There is no problem if I install it on my global env. I use Linux. Is there some I missed?

Thank you

softzer0 commented 7 months ago

I'm experiencing similar problem right now with Anaconda environment:

(base) PS D:\shopify_django_app> python .\google_new.py
Traceback (most recent call last):
  File "D:\shopify_django_app\google_new.py", line 1, in <module>
    from google.oauth2.credentials import Credentials
  File "D:\shopify_django_app\google.py", line 3, in <module>
    from googleapiclient.discovery import build
  File "C:\Users\Mihailo\anaconda3\lib\site-packages\googleapiclient\discovery.py", line 42, in <module>
    import google.api_core.client_options
ModuleNotFoundError: No module named 'google.api_core'; 'google' is not a package

However what was explained in the main post didn't happen in my case... Could it be that the order of installing those Google libraries messed that up?