# Uploading a Model (Python push\_to\_hub)

**URL:** <https://discuss.huggingface.co/t/uploading-a-model-python-push-to-hub/70626>\
**Category:** 🤗Hub\
**Created:** [January 25, 2024, 7:32pm UTC](https://discuss.huggingface.co/t/uploading-a-model-python-push-to-hub/70626 "2024-01-25T19:32:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaylub](https://avatars.discourse-cdn.com/v4/letter/k/c37758/32.png) [@kaylub](https://discuss.huggingface.co/u/kaylub)\
**Post date:** [January 25, 2024, 7:32pm UTC](https://discuss.huggingface.co/t/uploading-a-model-python-push-to-hub/70626/1 "2024-01-25T19:32:34Z")

</div>

I am trying to push a model to my model repo and it is giving me an error saying I dont have write access. I have created a write token and I am passing that into hugging face for authentication. I’m not sure what’s going wrong here.

It says I successfully login and have write access.

```auto
!huggingface-cli login

```

```auto

    _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
    _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
    _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
    _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
    _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|

    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) n
Token is valid (permission: write).
Your token has been saved to /root/.cache/huggingface/token
Login successful

```

Then I go to push the model and it does not work.

```auto
model.push_to_hub('kaylub/testing') #Private repo, I created to test this.

```

```auto
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py in hf_raise_for_status(response, endpoint_name)
    285 try:
--> 286 response.raise_for_status()
    287 except HTTPError as e:

10 frames
HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/models/kaylub/testing/preupload/main

The above exception was the direct cause of the following exception:

HfHubHTTPError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py in hf_raise_for_status(response, endpoint_name)
    331 # Convert `HTTPError` into a `HfHubHTTPError` to display request information
    332 # as well (request id and/or server error message)
--> 333 raise HfHubHTTPError(str(e), response=response) from e
    334 
    335 

HfHubHTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/models/kaylub/testing/preupload/main (Request ID: Root=1-65b2b5c0-1f99eb0b23b2db4c672e41f1;cec81efe-b59d-483c-ba38-da4dcddca49a)

Forbidden: you must use a write token to upload to a repository.

```

I also tried to passing the token into push\_to\_hub and tried authenticating using the hugging face python package but it didnt seem to work either.

---

<div class="post-metadata">

**Author:** ![futureProofGlitch](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futureproofglitch/32/23824_2.png) [@futureProofGlitch](https://discuss.huggingface.co/u/futureProofGlitch)\
**Post date:** [February 13, 2024, 8:39pm UTC](https://discuss.huggingface.co/t/uploading-a-model-python-push-to-hub/70626/2 "2024-02-13T20:39:46Z")

</div>

I am facing this issue and am unable to push any finetuned transformer model to 🤗Hub. Did you resolve this? Is there any resolution for this?

---

<div class="post-metadata">

**Author:** ![Boltuzamaki](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/boltuzamaki/32/24437_2.png) [@Boltuzamaki](https://discuss.huggingface.co/u/Boltuzamaki)\
**Post date:** [March 3, 2024, 8:47pm UTC](https://discuss.huggingface.co/t/uploading-a-model-python-push-to-hub/70626/3 "2024-03-03T20:47:27Z")

</div>

do

```auto
import huggingface_hub
huggingface_hub.logout()

```

then again login with write token. This should work.
