Windows 11 安装 Dify 完整指南 非docker情况

打印 上一主题 下一主题

主题 890|帖子 890|积分 2670

Windows 11 安装 Dify 完整指南

前置要求



  • Python 3.11
  • Node.js 18+
  • PostgreSQL 14+
  • Redis for Windows
  • Git
  • Ollama (可选,用于本地模子)
具体安装步骤

1. 安装必要软件


  • Python 3.11

    • 从 https://www.python.org/downloads/release/python-3110/ 下载安装
    • 安装时勾选 “Add Python to PATH”

  • Node.js 18

    • 从 https://nodejs.org/ 下载 18.x LTS 版本
    • 设置 npm 镜像:
      1. npm config set registry https://registry.npmmirror.com
      复制代码

  • PostgreSQL 14

    • 从 https://www.postgresql.org/download/windows/ 下载
    • 记住设置的超级用户暗码
    • 默认端口 5432

  • Redis

    • 从 https://github.com/microsoftarchive/redis/releases 下载
    • 安装 Redis-x64-3.0.504.msi

requirements.txt
  1. # requirements.txt
  2. anthropic==0.23.1
  3. authlib==1.3.1
  4. azure-ai-inference==1.0.0b8
  5. azure-ai-ml==1.20.0
  6. azure-identity==1.16.1
  7. beautifulsoup4==4.12.2
  8. boto3==1.36.12
  9. bs4==0.0.1
  10. cachetools==5.3.0
  11. celery==5.4.0
  12. chardet==5.1.0
  13. cohere==5.2.4
  14. dashscope[tokenizer]==1.17.0
  15. fal-client==0.5.6
  16. flask==3.1.0
  17. flask-compress==1.17
  18. flask-cors==4.0.0
  19. flask-login==0.6.3
  20. flask-migrate==4.0.7
  21. flask-restful==0.3.10
  22. flask-sqlalchemy==3.1.1
  23. gevent==24.11.1
  24. gmpy2==2.2.1
  25. google-ai-generativelanguage==0.6.9
  26. google-api-core==2.18.0
  27. google-api-python-client==2.90.0
  28. google-auth==2.29.0
  29. google-auth-httplib2==0.2.0
  30. google-cloud-aiplatform==1.49.0
  31. google-generativeai==0.8.1
  32. googleapis-common-protos==1.63.0
  33. gunicorn==23.0.0
  34. httpx[socks]==0.27.0
  35. huggingface-hub==0.16.4
  36. jieba==0.42.1
  37. langfuse==2.51.3
  38. langsmith==0.1.77
  39. mailchimp-transactional==1.0.50
  40. markdown==3.5.1
  41. nomic==3.1.2
  42. novita-client==0.5.7
  43. numpy==1.26.4
  44. oci==2.135.1
  45. openai==1.61.0
  46. openpyxl==3.1.5
  47. opik==1.3.4
  48. pandas[performance,excel]==2.2.2
  49. pandas-stubs==2.2.3.241009
  50. psycogreen==1.0.2
  51. psycopg2-binary==2.9.6
  52. pycryptodome==3.19.1
  53. pydantic==2.9.2
  54. pydantic-settings==2.6.0
  55. pydantic_extra_types==2.9.0
  56. pyjwt==2.8.0
  57. pypdfium2==4.30.0
  58. python-docx==1.1.0
  59. python-dotenv==1.0.1
  60. pyyaml==6.0.1
  61. readabilipy==0.2.0
  62. redis[hiredis]==5.0.3
  63. replicate==0.22.0
  64. resend==0.7.0
  65. sagemaker==2.231.0
  66. scikit-learn==1.5.1
  67. sentry-sdk[flask]==1.44.1
  68. sqlalchemy==2.0.29
  69. starlette==0.41.0
  70. tencentcloud-sdk-python-hunyuan==3.0.1294
  71. tiktoken==0.8.0
  72. tokenizers==0.15.0
  73. transformers==4.35.0
  74. unstructured[docx,epub,md,msg,ppt,pptx]==0.16.1
  75. validators==0.21.0
  76. volcengine-python-sdk[ark]==1.0.98
  77. websocket-client==1.7.0
  78. xinference-client==0.15.2
  79. yarl==1.18.3
  80. youtube-transcript-api==0.6.2
  81. zhipuai==2.1.5
  82. # Indirect Dependencies
  83. kaleido==0.2.1
  84. rank-bm25==0.2.2
  85. safetensors==0.4.3
  86. # Tools Dependencies
  87. arxiv==2.1.0
  88. cloudscraper==1.2.71
  89. duckduckgo-search==6.3.0
  90. jsonpath-ng==1.6.1
  91. matplotlib==3.8.2
  92. mplfonts==0.0.8
  93. newspaper3k==0.2.8
  94. nltk==3.9.1
  95. numexpr==2.9.0
  96. pydub==0.25.1
  97. qrcode==7.4.2
  98. twilio==9.0.4
  99. vanna[postgres,mysql,clickhouse,duckdb,oracle]==0.7.5
  100. wikipedia==1.4.0
  101. yfinance==0.2.40
  102. # Storage Dependencies
  103. azure-storage-blob==12.13.0
  104. bce-python-sdk==0.9.23
  105. cos-python-sdk-v5==1.9.30
  106. esdk-obs-python==3.24.6.1
  107. google-cloud-storage==2.16.0
  108. opendal==0.45.12
  109. oss2==2.18.5
  110. supabase==2.8.1
  111. tos==2.7.1
  112. # Vector Database Dependencies
  113. alibabacloud_gpdb20160503==3.8.0
  114. alibabacloud_tea_openapi==0.3.9
  115. chromadb==0.5.20
  116. clickhouse-connect==0.7.16
  117. couchbase==4.3.0
  118. elasticsearch==8.14.0
  119. opensearch-py==2.4.0
  120. oracledb==2.2.1
  121. pgvecto-rs[sqlalchemy]==0.2.1
  122. pgvector==0.2.5
  123. pymilvus==2.5.0
  124. pymochow==1.3.1
  125. pyobvector==0.1.6
  126. qdrant-client==1.7.3
  127. tcvectordb==1.3.2
  128. tidb-vector==0.0.9
  129. upstash-vector==0.6.0
  130. volcengine-compat==1.0.156
  131. weaviate-client==3.21.0
  132. # Development Dependencies
  133. coverage==7.2.4
  134. faker==32.1.0
  135. mypy==1.13.0
  136. pytest==8.3.2
  137. pytest-benchmark==4.0.0
  138. pytest-env==1.1.3
  139. pytest-mock==3.14.0
  140. types-beautifulsoup4==4.12.0.20241020
  141. types-flask-cors==5.0.0.20240902
  142. types-flask-migrate==4.1.0.20250112
  143. types-html5lib==1.1.11.20241018
  144. types-openpyxl==3.1.5.20241225
  145. types-protobuf==5.29.1.20241207
  146. types-psutil==6.1.0.20241221
  147. types-psycopg2==2.9.21.20250121
  148. types-python-dateutil==2.9.0.20241206
  149. types-pytz==2024.2.0.20241221
  150. types-pyyaml==6.0.12.20241230
  151. types-regex==2024.11.6.20241221
  152. types-requests==2.32.0.20241016
  153. types-six==1.17.0.20241205
  154. types-tqdm==4.67.0.20241221
  155. # Linting Dependencies
  156. dotenv-linter==0.5.0
  157. ruff==0.9.2
复制代码
2. 下载并配置 Dify

  1. # 克隆项目
  2. git clone https://gitee.com/dify_ai/dify.git
  3. cd dify
  4. # 创建并激活虚拟环境
  5. cd api
  6. python -m venv venv
  7. .\venv\Scripts\activate
  8. # 更新 pip
  9. python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
  10. # 安装基础依赖
  11. pip install wheel setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple
  12. # 安装项目依赖
  13. pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  14. # 安装 PyTorch 和 AI 相关依赖
  15. pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 -i https://pypi.tuna.tsinghua.edu.cn/simple
  16. pip install transformers accelerate optimum -i https://pypi.tuna.tsinghua.edu.cn/simple
复制代码
3. 配置情况

  1. # 复制环境配置文件
  2. copy .env.example .env
复制代码
修改 .env 文件中的关键配置:
  1. DB_USERNAME=postgres
  2. DB_PASSWORD=你的PostgreSQL密码
  3. DB_HOST=localhost
  4. DB_PORT=5432
  5. DB_DATABASE=dify
  6. OLLAMA_API_BASE_URL=http://localhost:11434
  7. OLLAMA_PROXY_API_KEY=your_key_here
复制代码
4. 初始化数据库

  1. # 创建数据库
  2. psql -U postgres
  3. CREATE DATABASE dify;
  4. \q
  5. # 初始化数据库架构
  6. flask db upgrade
  7. flask init
复制代码
5. 安装前端依赖

  1. # 切换到前端目录
  2. cd ..\web
  3. # 安装依赖
  4. npm install
  5. # 复制前端环境配置
  6. copy .env.example .env.local
复制代码
6. 启动服务

  1. # 终端 1 - 启动后端 (在 api 目录下)
  2. # 确保激活了虚拟环境 (venv)
  3. flask run --debug --host 0.0.0.0 --port 5001
  4. # 终端 2 - 启动前端 (在 web 目录下)
  5. npm run dev
复制代码
验证安装


  • 访问 http://localhost:3000
  • 默认管理员账号:admin@foo.bar
  • 默认暗码:12345678
常见问题办理


  • 虚拟情况问题
    1. # 检查 Python 路径
    2. where python
    3. # 应显示: C:\path\to\dify\api\venv\Scripts\python.exe
    复制代码
  • 依赖安装失败
    1. # 使用预编译包
    2. pip install 包名 --only-binary :all:
    复制代码
  • 服务启动检查

    • PostgreSQL 服务是否运行
    • Redis 服务是否运行
    • 虚拟情况是否激活
    • .env 配置是否精确

  • 日志检察

    • 后端日志:api/logs/
    • 使用 debug 模式:flask run --debug

注意要进入目次api

Dify Backend API 安装与运行

Poetry 安装

  1. # 安装 Poetry
  2. pip install poetry
  3. # 安装 Poetry shell 插件
  4. poetry self add poetry-plugin-shell
复制代码
Dify 依赖安装

  1. # 指定 Python 版本
  2. poetry env use 3.12
  3. # 安装项目依赖
  4. poetry install
复制代码
数据库迁移

  1. poetry run python -m flask db upgrade
复制代码
启动后端服务

  1. # 启动后端服务
  2. poetry run python -m flask run --host 0.0.0.0 --port=5001 --debug
复制代码
启动异步使命

  1. poetry run python -m celery -A app.celery worker \
  2.     -P gevent -c 1 \
  3.     --loglevel INFO \
  4.     -Q dataset,generation,mail,ops_trace,app_deletion
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

缠丝猫

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表