* doc rewrite * changes * changes * tip * changes * notebook * add changeset * history * add * quickstart done * readme * changes * quickstart * changes * reorder * link * changes * changes * changes * quickstart done * readme * quickstart * quickstart' * moving around * spaces * readme * guides * guides * links * readme * readme * readme * readme * readme * readme * readme * readme * readme * readme * email address * add changeset * shorten quickstart * readme * Update README.md * readme * changes * Update guides/01_getting-started/01_quickstart.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/01_getting-started/01_quickstart.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/01_getting-started/01_quickstart.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * changes * changes * remove gr.Interface.load * guides * changes * more changes * changes * sharing * concurrency * changes * changes * components * key features * event listeners * features * notebook * test * guides * changes * changes * changes * transitions * readme links * links * links * guides * new gif * add gif * update gif * Update guides/02_building-interfaces/01_more-on-examples.md * Update guides/03_building-with-blocks/01_blocks-and-event-listeners.md * Update guides/01_getting-started/01_quickstart.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/01_getting-started/02_key-features.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/01_getting-started/02_key-features.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/02_building-interfaces/00_the-interface-class.md Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> * Update guides/01_getting-started/01_quickstart.md Co-authored-by: Hannah <hannahblair@users.noreply.github.com> * Update guides/01_getting-started/02_key-features.md Co-authored-by: Hannah <hannahblair@users.noreply.github.com> * Update guides/01_getting-started/02_key-features.md Co-authored-by: Hannah <hannahblair@users.noreply.github.com> * changes * replace space * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
3.9 KiB
Installing Gradio in a Virtual Environment
Tags: INSTALLATION
In this guide, we will describe step-by-step how to install gradio
within a virtual environment. This guide will cover both Windows and MacOS/Linux systems.
Virtual Environments
A virtual environment in Python is a self-contained directory that holds a Python installation for a particular version of Python, along with a number of additional packages. This environment is isolated from the main Python installation and other virtual environments. Each environment can have its own independent set of installed Python packages, which allows you to maintain different versions of libraries for different projects without conflicts.
Using virtual environments ensures that you can work on multiple Python projects on the same machine without any conflicts. This is particularly useful when different projects require different versions of the same library. It also simplifies dependency management and enhances reproducibility, as you can easily share the requirements of your project with others.
Installing Gradio on Windows
To install Gradio on a Windows system in a virtual environment, follow these steps:
-
Install Python: Ensure you have Python 3.8 or higher installed. You can download it from python.org. You can verify the installation by running
python --version
orpython3 --version
in Command Prompt. -
Create a Virtual Environment: Open Command Prompt and navigate to your project directory. Then create a virtual environment using the following command:
python -m venv gradio-env
This command creates a new directory
gradio-env
in your project folder, containing a fresh Python installation. -
Activate the Virtual Environment: To activate the virtual environment, run:
.\gradio-env\Scripts\activate
Your command prompt should now indicate that you are working inside
gradio-env
. Note: you can choose a different name thangradio-env
for your virtual environment in this step. -
Install Gradio: Now, you can install Gradio using pip:
pip install gradio
-
Verification: To verify the installation, run
python
and then type:import gradio as gr print(gr.__version__)
This will display the installed version of Gradio.
Installing Gradio on MacOS/Linux
The installation steps on MacOS and Linux are similar to Windows but with some differences in commands.
-
Install Python: Python usually comes pre-installed on MacOS and most Linux distributions. You can verify the installation by running
python --version
in the terminal (note that depending on how Python is installed, you might have to usepython3
instead ofpython
throughout these steps).Ensure you have Python 3.8 or higher installed. If you do not have it installed, you can download it from python.org.
-
Create a Virtual Environment: Open Terminal and navigate to your project directory. Then create a virtual environment using:
python -m venv gradio-env
Note: you can choose a different name than
gradio-env
for your virtual environment in this step. -
Activate the Virtual Environment: To activate the virtual environment on MacOS/Linux, use:
source gradio-env/bin/activate
-
Install Gradio: With the virtual environment activated, install Gradio using pip:
pip install gradio
-
Verification: To verify the installation, run
python
and then type:import gradio as gr print(gr.__version__)
This will display the installed version of Gradio.
By following these steps, you can successfully install Gradio in a virtual environment on your operating system, ensuring a clean and managed workspace for your Python projects.