Toggle navigation
Toggle navigation
This project
Loading...
Sign in
zhouhui.jiang
/
Test_LangGraph
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
zhouhui.jiang
2025-11-11 15:12:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
01742741806f5d2938761ddfe4295950a059b6be
01742741
1 parent
4dd1601a
update
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
0 deletions
deploy/README.md
deploy/README.md
View file @
0174274
...
...
@@ -33,6 +33,8 @@ git clone <仓库地址> langgraph
### 2. 安装依赖
#### 标准安装方式(如果系统 pip 正常)
```
bash
cd
~/langgraph
python3 -m venv venv
...
...
@@ -42,6 +44,161 @@ pip install -r requirements.txt
pip install uvicorn python-dotenv
```
#### 故障排除:如果虚拟环境创建失败
**问题1:`ensurepip` 失败或 pip 损坏**
如果遇到以下错误:
```
Error: Command '['.../venv/bin/python3', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
```
**解决方案:使用 --without-pip 创建虚拟环境**
```
bash
cd
~/langgraph
# 1. 检查系统 pip 是否可用
python3 -m pip --version
# 2. 如果系统 pip 损坏,先修复系统 pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
# 3. 使用 --without-pip 创建虚拟环境
python3 -m venv venv --without-pip
# 4. 激活虚拟环境
source
venv/bin/activate
# 5. 使用系统 pip 安装 pip、setuptools、wheel 到虚拟环境
# 注意:将 python3.12 替换为你的实际 Python 版本(如 python3.10)
python3 -m pip install --target venv/lib/python3.12/site-packages pip setuptools wheel
# 6. 验证 pip 是否可用
python3 -m pip --version
# 7. 安装项目依赖(使用 python3 -m pip 更可靠)
python3 -m pip install -r requirements.txt
python3 -m pip install uvicorn python-dotenv
```
**问题2:系统 pip 损坏(ModuleNotFoundError: No module named 'distutils')**
如果遇到
`distutils`
模块缺失错误:
```
bash
# 1. 重新安装系统 pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
# 2. 验证
python3 -m pip --version
# 3. 然后按照"问题1"的解决方案继续
```
**问题3:网络问题无法下载 get-pip.py**
如果无法访问
`bootstrap.pypa.io`
:
```
bash
# 方法1:使用国内镜像(如果可用)
curl https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/get-pip.py -o get-pip.py
# 注意:如果下载的是 HTML 重定向页面,需要使用方法2
# 方法2:直接使用系统 pip 安装到虚拟环境(推荐)
cd
~/langgraph
python3 -m venv venv --without-pip
source
venv/bin/activate
# 退出虚拟环境,使用系统 pip
deactivate
# 注意:将 python3.12 替换为你的实际 Python 版本
python3 -m pip install --target venv/lib/python3.12/site-packages pip setuptools wheel
# 重新激活虚拟环境
source
venv/bin/activate
python3 -m pip install -r requirements.txt
python3 -m pip install uvicorn python-dotenv
```
#### 完整安装流程(推荐,适用于所有情况)
```
bash
cd
~/langgraph
# 步骤1:检查 Python 和 pip
python3 --version
python3 -m pip --version
# 步骤2:如果 pip 不可用,修复系统 pip
if
! python3 -m pip --version > /dev/null 2>&1;
then
echo
"修复系统 pip..."
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
fi
# 步骤3:创建虚拟环境
if
[
-d
"venv"
]
;
then
echo
"清理旧的虚拟环境..."
rm -rf venv
fi
# 获取 Python 版本号(如 3.12)
PYTHON_VERSION
=
$(
python3 --version | awk
'{print $2}'
| cut -d. -f1,2
)
# 尝试标准方式创建
if
! python3 -m venv venv 2>/dev/null;
then
echo
"标准方式失败,使用 --without-pip 方式..."
python3 -m venv venv --without-pip
# 使用系统 pip 安装基础包
python3 -m pip install --target venv/lib/python
${
PYTHON_VERSION
}
/site-packages pip setuptools wheel
fi
# 步骤4:激活虚拟环境
source
venv/bin/activate
# 步骤5:安装依赖
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install uvicorn python-dotenv
# 步骤6:验证安装
python3 -m pip list | grep -E
"langgraph|uvicorn|dotenv"
echo
"✅ 依赖安装完成!"
```
#### 验证安装
```
bash
# 激活虚拟环境
source
venv/bin/activate
# 检查 Python 路径(应该指向 venv)
which python
# 应该显示:/home/username/Test_LangGraph/venv/bin/python
# 检查已安装的包
pip list
# 测试导入关键模块
python -c
"import langgraph; print('LangGraph OK')"
python -c
"import uvicorn; print('Uvicorn OK')"
```
#### 注意事项
1.
**Python 版本**
:确保使用 Python 3.8+,推荐 Python 3.10+
2.
**虚拟环境路径**
:如果 Python 版本不是 3.12,将命令中的
`python3.12`
替换为实际版本(如
`python3.10`
)
3.
**权限问题**
:如果遇到权限错误,确保对项目目录有写权限
4.
**网络问题**
:如果网络不稳定,考虑使用国内镜像源或离线安装
### 3. 配置环境变量
```
bash
...
...
Please
register
or
login
to post a comment