Skip to content

Package writes to "apiclient" directory when installed #2485

Closed

Description

@kruton

Environment details

  • OS type and version: Linux
  • Python version: 3.12.5
  • pip version: 24.2
  • google-api-python-client version: 2.145.0

Steps to reproduce

  1. python -m virtualenv venv
  2. . venv/bin/activate
  3. pip install api-client
  4. python -c 'from apiclient import HeaderAuthentication'
  5. pip install firebase-admin
  6. python -c 'from apiclient import HeaderAuthentication'

I expect step 6 to be the same as step 4 here, but it results in a stack trace since firebase-admin depends on google-api-python-client which is overwriting .../site-packages/apiclient/. What's even worse is that some package managers (e.g., poetry) seem to install this in a random order resulting in it sometimes working and sometimes not.

Code example

from apiclient import HeaderAuthentication

Stack trace

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'HeaderAuthentication' from 'apiclient' (/private/tmp/test1/venv/lib/python3.11/site-packages/apiclient/__init__.py)

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Sep 20, 2024
  2. ohmayr commented on Sep 20, 2024

    @ohmayr
    Contributor

    Thanks for reporting this @kruton. We'll take a look into this.

  3. kruton commented on Dec 6, 2024

    @kruton
    Author

    I rebased the pull request #2486 onto the newest release.

  4. kruton commented on Jan 31, 2025

    @kruton
    Author

    Hi, @ohmayr any chance this could be merged? I cut out the translated documentation changes to make it easier to review. The documentation should be generated automatically from googleapiclient/discovery.py next time pydoc is run.

  5. daniel-sanche commented on Jan 28, 2026

    @daniel-sanche
    Contributor

    Thanks for putting the fix together, but unfortunately this repo contains legacy versions of our GCP libraries and is in maintenance mode, so we try not to make major changes here. Removing the apiclient alias would be a breaking change, which could have a large impact on existing user code, so it's not a change we'll be able to make at this time

    If it's at all possible, I'd recommend trying to move to the more modern gapic libraries (This is the gapic equivalent of firebase admin). If that's not possible, you may be able to make a fork of this code to accomplish what you need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions