# How to pin version of spaces package?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702%3E%5C
**Category:** Spaces\
**Created:** [September 28, 2023, 11:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702 "2023-09-28T11:44:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jannisborn](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@jannisborn](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjannisborn)%5C
**Post date:** [September 28, 2023, 11:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702%2F1 "2023-09-28T11:44:46Z")

</div>

Dependencies of HF spaces can be specified in `requirements.txt`.

When running the build (e.g., [here](https://huggingface.co/spaces/GT4SD/molecular_properties)), the docker image has a line:

```auto
RUN --mount=target=requirements.txt,source=requirements.txt pip install --no-cache-dir -r requirements.txt

```

that takes care of that. However, afterwards there is another line:

```auto
RUN pip install --no-cache-dir gradio[oauth]==3.9.1 spaces==0.14.0

```

Which essentially implies that all versions specified in `requirements.txt` for the packages `gradio`, `spaces` and their dependencies are useless because they are overwritten here.  
In this example, `gradio` is set to `3.9.1` because of the YAML config in `README.md` but there is no way to specify the `spaces` version. In practice this means that I have no control over the version of `spaces` and its dependencies (e.g., `httpcore`) and all my spaces are now failing with:

```auto
  File "/home/user/.local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 161, in HTTP11Connection
    self, event: h11.Event, timeout: Optional[float] = None
AttributeError: module 'h11' has no attribute 'Event'

```

Which could normally easily be fixed by pinning `httpcore==0.15`. I checked past builds and `spaces` was also being installed there, however, the critical line was

```auto
RUN pip install --no-cache-dir gradio[oauth]==3.9.1 spaces==0.12.0

```

which resulted in versions that were not conflicting.

Question: How do I properly pin the version of the `spaces` package?

---

<div class="post-metadata">

**Author:** ![jannisborn](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@jannisborn](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjannisborn)%5C
**Post date:** [October 2, 2023, 9:58pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702%2F2 "2023-10-02T21:58:12Z")

</div>

Can’t believe that I’m the only person for whom this is causing trouble!

It seems that currently _all_ deployed gradio webapps will use `spaces==0.14.0` (now even `spaces==0.15.0` that just became available). This `spaces` version relies e.g., on `httpcore>=0.18.0`, so effectively it seems to impose strong restrictions on which packages can be used

---

<div class="post-metadata">

**Author:** ![jannisborn](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@jannisborn](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjannisborn)%5C
**Post date:** [October 5, 2023, 7:13am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702%2F3 "2023-10-05T07:13:27Z")

</div>

Just for future readers, I was able to resolve this issue by changing `sdk_version` of `gradio` in `README.txt` from `3.1.0` to `3.46.0`. Then I just had to add `h11==0.13.0` and now all my apps are back up

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [October 5, 2023, 5:14pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pin-version-of-spaces-package%2F56702%2F4 "2023-10-05T17:14:46Z")

</div>

thanks for the update, indeed using the latest Gradio will be the best recommendation.
