| ```bash | ```bash | ||||
| sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env | sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env | ||||
| ``` | ``` | ||||
| 3.5 If you use Anaconda, create a new environment and activate it | |||||
| 4. If you use Anaconda, create a new environment and activate it | |||||
| ```bash | ```bash | ||||
| conda create --name dify python=3.10 | conda create --name dify python=3.10 | ||||
| conda activate dify | conda activate dify | ||||
| ``` | ``` | ||||
| 4. Install dependencies | |||||
| 5. Install dependencies | |||||
| ```bash | ```bash | ||||
| pip install -r requirements.txt | pip install -r requirements.txt | ||||
| ``` | ``` | ||||
| 5. Run migrate | |||||
| 6. Run migrate | |||||
| Before the first launch, migrate the database to the latest version. | Before the first launch, migrate the database to the latest version. | ||||
| pip install -r requirements.txt --upgrade --force-reinstall | pip install -r requirements.txt --upgrade --force-reinstall | ||||
| ``` | ``` | ||||
| 6. Start backend: | |||||
| 7. Start backend: | |||||
| ```bash | ```bash | ||||
| flask run --host 0.0.0.0 --port=5001 --debug | flask run --host 0.0.0.0 --port=5001 --debug | ||||
| ``` | ``` | ||||
| 7. Setup your application by visiting http://localhost:5001/console/api/setup or other apis... | |||||
| 8. If you need to debug local async processing, you can run `celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail`, celery can do dataset importing and other async tasks. | |||||
| 8. Setup your application by visiting http://localhost:5001/console/api/setup or other apis... | |||||
| 9. If you need to debug local async processing, please start the worker service by running | |||||
| `celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail`. | |||||
| The started celery app handles the async tasks, e.g. dataset importing and documents indexing. |