How to install a specific version of gradio in Spaces?

Hi,

The last version of gradio (2.7.0) comes with a display bug (launch this notebook diff_texts.ipynb from gradio at HighlightedText).

With the version 2.6.4 of gradio, there was no display bug:

However, when you create an App with gradio, Hugging Face Spaces says that the gradio package comes pre-installed at version 2.2.6. I think this text needs an update. (cc @sgugger)

More, I did try to create a new Spaces App with gradio. In the requirements.txt file, I added gradio==2.6.4 but it did not work.

How can I install the gradio version of my choice for a Spaces App? Thank you.

Note: see this issue on gradio github about the version 2.7.0 and HighlightedText.

Sorry about that! We’re fixing the bug but for now you can install a specific version of Gradio by adding lines like this at the top of your app.py file:

import os
os.system("pip uninstall -y gradio")
os.system("pip install gradio==2.6.4")
2 Likes

Is there still no better way to do this?

1 Like

Now you can specify the Gradio version you want with sdk_version in the README.md. Here is an example: README.md · multimodalart/mindseye-lite at main

2 Likes

Great! Thanks!