Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,762 Bytes
0a440b6 50897a8 0a440b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
To run Gradio apps locally using Windows Subsystem for Linux (WSL) and Visual Studio Code (VSCode), follow these steps:
## **1. Set Up WSL**
### **Enable WSL**
1. **Windows Features Dialog:**
- Open the Windows search bar, type "features," and select *Turn Windows Features on or off*.
- Scroll down and check *Windows Subsystem for Linux*.
- Click *OK* and restart your computer.
2. **PowerShell:**
- Open PowerShell as an Administrator and run:
```powershell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```
- Restart your computer when prompted.
### **Install a Linux Distro**
1. Open the Microsoft Store and search for a Linux distribution (e.g., Ubuntu).
2. Install and launch the distribution.
3. Follow the prompts to complete the installation and create a user ID and password.
## **2. Set Up Visual Studio Code with WSL**
### **Install VSCode and WSL Extension**
1. Download and install [Visual Studio Code](https://code.visualstudio.com/).
2. Install the *Remote - WSL* extension from the VSCode marketplace.
### **Open a WSL Terminal in VSCode**
1. Open your WSL terminal (e.g., Ubuntu).
2. Navigate to your project directory.
3. Type `code .` to open the current directory in VSCode.
## **3. Install and Run Gradio in a Virtual Environment**
### **Create a Virtual Environment**
1. In your WSL terminal, navigate to your project directory:
```bash
cd /path/to/your/project
```
2. Create a virtual environment:
```bash
python3 -m venv gradio-env
```
3. Activate the virtual environment:
```bash
source gradio-env/bin/activate
```
### **Install Gradio**
1. With the virtual environment activated, install Gradio:
```bash
pip install gradio
```
### **Run the App**
```
2. Run the Gradio app:
```bash
python app.py
```
3. The app will open in a browser at `http://localhost:7860`.
### **Hot Reload Mode (Optional)**
For development convenience, you can use Gradio's hot reload mode:
```bash
gradio app.py
```
This setup allows you to develop and run Gradio apps efficiently using WSL and VSCode, leveraging the power of a Linux environment on a Windows machine[1][3][4][5].
Citations:
[1] https://code.visualstudio.com/docs/remote/wsl-tutorial
[2] https://learn.microsoft.com/en-us/windows/ai/toolkit/toolkit-fine-tune
[3] https://www.gradio.app/guides/quickstart
[4] https://code.visualstudio.com/docs/remote/wsl
[5] https://www.gradio.app/guides/installing-gradio-in-a-virtual-environment
To automatically create and update a requirements.txt file for your Python application, you have several options. Here are the most effective methods:
# Updating the requirements.txt
```bash
pip freeze > requirements.txt
```
|