Google-api-python-client: cannot import name 'mtls'

Created on 2 Jun 2020  路  11Comments  路  Source: googleapis/google-api-python-client

This appears to be a bug with version 1.9 caused by https://github.com/googleapis/google-api-python-client/pull/917

Environment details

  • OS type and version: OS X 10.15.4
  • Python version: 3.6.10
  • pip version: 20.0.02
  • google-api-python-client version: 1.9.1

Steps to reproduce

  1. python -c "import googleapiclient.discovery"

Stack trace

----> 1 import googleapiclient.discovery

~/miniconda3/envs/surround-cp/lib/python3.6/site-packages/googleapiclient/discovery.py in <module>
     48 import uritemplate
     49 import google.api_core.client_options
---> 50 from google.auth.transport import mtls
     51 from google.auth.exceptions import MutualTLSChannelError
     52

ImportError: cannot import name 'mtls'
external p2 bug

Most helpful comment

@A-Sm1th I tested google-auth 1.17.2 and it worked fine.

(tmp) $ python -m pip freeze
cachetools==4.1.0
google-auth==1.17.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
rsa==4.6
six==1.15.0
(tmp) $ python
Python 3.6.9 (default, Jan 26 2020, 20:47:45) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.auth.transport import mtls
>>> 

All 11 comments

CC: @busunkim96 , @arithmetic1728

I see that my google-auth version is old (1.6.3), so maybe this is actually an issue of my not upgrading all dependencies properly.

@nitramsivart yes, please upgrade google-auth. mtls is not defined in the old version.

Thank you, that resolved my issue!

Note, this is still an issue when I install this package with conda install, because these dependency requirements haven't been updated in the conda recipe: https://github.com/conda-forge/google-api-python-client-feedstock/issues/39

Hmm, I'm not entirely sure how this package is published to conda. @meredithslota?

Pretty sure it's published using conda-smithy, as described a bit more in README of this reop: https://github.com/conda-forge/google-api-python-client-feedstock

What's unclear to me is if anybody owns keeping this up to date, or it's just as needed

Closing as this has been addressed by the folks who manage the repo mentioned above.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-61-286c2210acad> in <module>
      4 import httplib2
      5 
----> 6 from googleapiclient.discovery import build
      7 
      8 SCOPES = [

~/.local/lib/python3.6/site-packages/googleapiclient/discovery.py in <module>
     48 import uritemplate
     49 import google.api_core.client_options
---> 50 from google.auth.transport import mtls
     51 from google.auth.exceptions import MutualTLSChannelError
     52 

ImportError: cannot import name 'mtls'

I still get the error even though my pip list shows the version google-auth 1.17.2

I am using that in a Jupyter Notebook with Python 3.

@A-Sm1th Can you double check the version? The latest published version is 1.9.2

@A-Sm1th I tested google-auth 1.17.2 and it worked fine.

(tmp) $ python -m pip freeze
cachetools==4.1.0
google-auth==1.17.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
rsa==4.6
six==1.15.0
(tmp) $ python
Python 3.6.9 (default, Jan 26 2020, 20:47:45) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.auth.transport import mtls
>>> 
Was this page helpful?
0 / 5 - 0 ratings