installation.md 3.4 KB

from pcweb import constants
import reflex as rx
app_name = "my_app_name"
default_url = "http://localhost:3000"

Installation

Reflex requires Python 3.8+.

Virtual Environment

We highly recommend creating a virtual environment for your project.

venv is the standard option. conda and poetry are some alternatives.

Install on macOS/Linux

We will go with venv here.

Prerequisites

macOS (Apple Silicon) users should install Rosetta 2. Run this command:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

Create the project directory

Replace {app_name} with your project name. Switch to the new directory.

mkdir {app_name}
cd {app_name}

Setup virtual environment

python3 -m venv .venv
source .venv/bin/activate
# Error `No module named venv`

While Python typically ships with `venv` it is not installed by default on some systems.
If so, please install it manually. E.g. on Ubuntu Linux, run `sudo apt-get install python3-venv`.

Install Reflex package

Reflex is available as a pip package.

pip install reflex
# Error `command not found: pip`

While Python typically ships with `pip` as the standard package management tool, it is not installed by default on some systems.
You may need to install it manually. E.g. on Ubuntu Linux, run `apt-get install python3-pip`

Initialize the project

reflex init
# Error `command not found: reflex`
If you install Reflex with no virtual environment and get this error it means your `PATH` cannot find the reflex package. 
A virtual environment should solve this problem, or you can try running `python3 -m` before the reflex command.

Install on Windows

Prerequisites

For Windows users, we recommend using Windows Subsystem for Linux (WSL) for optimal performance.

WSL users should refer to instructions for Linux above.

For the rest of this section we will work with native Windows (non-WSL).

We will go with venv here, for virtual environments.

Create a new project directory

mkdir {app_name}
cd {app_name}

Setup virtual environment

py -3 -m venv .venv
.venv\\Scripts\\activate

Install Reflex package

pip install reflex

Initialize the project

reflex init
# Error `command not found: reflex`

The Reflex framework includes the `reflex` command line (CLI) tool. Using a virtual environment is highly recommended for a seamless experience (see below).",

Run the App

Run it in development mode:

reflex run

Your app runs at http://localhost:3000.

Reflex prints logs to the terminal. To increase log verbosity to help with debugging, use the --loglevel flag:

reflex run --loglevel debug

Reflex will hot reload any code changes in real time when running in development mode. Your code edits will show up on http://localhost:3000 automatically.

(Optional) Run the demo app

The demo app showcases some of Reflex's features.

reflex demo