[Python] Fixing Hugging Face Login Issue (504 Gateway Timeout & Invalid Token Error)

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    Issue I was trying to log in to Hugging Face CLI, but I kept getting the following error:

    requests.exceptions.HTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/api/whoami-v2

    Even after trying multiple fixes, the error persisted and eventually changed to:

    requests.exceptions.HTTPError: Invalid user token.

    What I Tried (But Didn’t Work)

    Logging in again using huggingface-cli login → Failed Upgrading Hugging Face Hub (pip install --upgrade huggingface_hub) → No effect Clearing cache & re-installing dependencies → Still the same error

    Final Solution That Worked After many attempts, the issue got fixed by setting up a virtual environment and reinstalling everything from scratch.

    Here’s what worked:

    python -m venv hf_env source hf_env/bin/activate # (Windows users: hf_env\Scripts\activate) pip install huggingface_hub huggingface-cli login

    Why This Works? A virtual environment creates an isolated Python environment, avoiding conflicts with existing dependencies. If there’s an issue with your global Python installation, this helps bypass it. It ensures a clean install of huggingface_hub without any corrupted files.

    If you’re facing similar issues, try this approach and let me know if it works for you!

    To help more developer who facing same problem.

    Continue reading...

Compartilhe esta Página