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 notebookdiff_texts.ipynbfrom gradio atHighlightedText).image1827×921 52.3 KBWith the version2.6.4of gradio, there was no display bug:image1815×787 39.6 KBHowever, 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)image1914×337 36.1 KBMore, I did try to create a new Spaces App with gradio. In therequirements.txtfile, I addedgradio==2.6.4but it did not work.image1166×550 29.4 KBHow can I install the gradio version of my choice for a Spaces App?Thank you.Note: see thisissue on gradio github about the version 2.7.0 and HighlightedText.
2022-01-14T15:59:47Z
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 yourapp.pyfile:import os
os.system("pip uninstall -y gradio")
os.system("pip install gradio==2.6.4")
2022-05-17T15:07:58Z
Is there still no better way to do this?
2022-05-19T14:40:55Z
Now you can specify the Gradio version you want withsdk_versionin  theREADME.md. Here is an example:README.md · multimodalart/mindseye-lite at main
2022-05-20T13:37:04Z
osanseviero:sdk_versionGreat! Thanks!
2023-04-15T23:49:46Z
Whilesdk_versioncan be used to specify an official version, can I use my own fork? In fact the version had been specified in therequirements.txt, I just want to suppressRUN pip install --no-cache-dir         gradio==3.24.1which canceled my installation.
2023-04-16T03:40:12Z
hi@JanuaryDesk, you can’t change the base docker for Gradio SDK. however you could build your own Dockerfile for you app and usesdk:dockerfor exampleDockerfile · sayakpaul/demo-docker-gradio at mainOn another note, you can always specify a custom gradio package on therequirements.txthave you tried that?git+https://github.com/username/gradio.git@branch#egg=gradio
2023-04-16T09:21:24Z
SDKgradioinstallation is after therequirements.txtinstallation so it doesn’t work. As I don’t figure out how to installpnpm, my current hack is to upload a zip filegradio.zipcontaining the working directory of my fork, then extract and install it in theapp.py, which looks like this:import os

def p(command):
    print("EXEC: " + command)
    os.system(command)

p("mkdir _gradio")
p("mv gradio.zip _gradio")
os.chdir("_gradio")

from zipfile import ZipFile

z = ZipFile("gradio.zip")
z.extractall()
p("pip uninstall gradio")
p("pip install -e .")
print(os.getcwd())
import sys
sys.path.append(os.getcwd())
os.chdir("..")Next time I need something like that I will try docker.
2023-04-17T20:50:03Z
hi@JanuaryDeskgreat, point, I’m looking internally the possibility to change the order! thanks
2023-11-20T14:12:32Z
Hi@radameswas there any progress on changing the requirements installation order? (i.e. controlling when requirements.txt is called with reference to the final system pip install - “–> RUN pip install --no-cache-dir 	streamlit==1.28.2 	“uvicorn>=0.14.0” 	spaces==0.18.0”). I’m aware this can be done by running os.system(“pip install …”), but this seems cumbersome.I am facing an issue now with my apps that run on haystack, since the upgrade to spaces==0.18.0 (as this version requires pydantic==2.5.1)
2023-11-22T06:31:18Z
hi@mtyrrellthe Docker file for our predefined SDKs (Gradio/Streamlit) are a bit inflexible. However we now offer apre-requirements.txtnot sure if that would helpful. Another alternative is to use a custom Dockerfile, here is a Gradio exampleDockerfile · SpacesExamples/Gradio-Docker-Template at main
2024-02-26T05:47:14Z
On another note, you can always specify a custom gradio package on therequirements.txthave you tried that?When I tried that after setting up Docker I got this error:Did you install Gradio from source files? You need to build the frontend by running /scripts/build_frontend.shAs I don’t figure out how to installpnpm, my current hack is to upload a zip filegradio.zipcontaining the working directory of my fork, then extract and install it in theapp.py, which looks like thisWhen I tried this I got this error:file:///home/user/app/_gradio does not appear to be a Python project: neither ‘setup.py’ nor ‘pyproject.toml’ found.I haven’t found a way to use a gradio fork in huggingface spaces.
2024-02-26T20:30:26Z
Hi@Yntec, Gradio has a complex build process. I recommend using any of the versions available on PyPI:gradio · PyPI.
2024-02-29T03:08:46Z
Thank you, but none of those versions work for me, as all the versions from 3.16.0 suffer from this bug:github.com/gradio-app/gradiocustom CSS can interfere with the hosting pageopened06:42PM - 15 Feb 23 UTCpngwnbug### Describe the bug

When e,mbedding a graido app, if that graiod app has cus…tom CSS then it can interfere with both the hosting page and any _other_ embedded demos.

This is because we got rid of the shadow DOM and standards css specificity rules apply.

We just need to scope the user provided CSS like we do with any other 'global' css. The lack of up to date css parsing libraries in python is annoying, so we can probably do something simpler. We only need to do this once when the app is created (we could also do it once per request but it is pointless work).

I haven't seen any reports for this so far and I don't think it is super common but it is probably the last major issue relating to our decision to remove the shadow dom.

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

Something like this will trigger it:

```py
css="a { color: pink !important}"
```

This will make _all_ links on the demo _and_ hosting page _and_ other embedded demos pink. 

### Screenshot

_No response_

### Logs

```shell
-
```


### System Info

```shell
-
```


### Severity

annoyingBreaking my spaces.Version 3.15.0 used to work, see this space built with it:huggingface.co700 AI Art Models Toy World - a Hugging Face Space by YntecTop 700 SD Image Models!If you duplicate it, fetching models takes so long it goes over the 30 minutes limit and it won’t build.I haven’t been able to update that space since January 25 because of this, and I need a custom gradio solution that is 3.15.0 but with gr.load implemented.But it seems not possible, killing the space.Update 2024/3/26: Everything working fine currently and I didn’t need to upgrade Gradio, yay!