Workaround deploys LangGraph on a Python 2.7 server
A blog author describes deploying a LangGraph agent project to a server whose system Python is 2.7, which cannot install uv or the Python 3.10+-dependent LangGraph CLI. The workaround is to generate a Dockerfile locally with `langgraph dockerfile`, transfer it and the project files to the server, and run only native `docker build`. The author also discusses regenerating files after configuration changes, transmitting referenced dependencies, base-image access, environment files, and Nginx buffering for streamed responses.
This first-hand workaround provides a concrete deployment path for LangGraph projects on legacy servers where the modern CLI cannot be installed.
前言
在本地用 LangGraph 开发完一个 Agent 项目,准备部署到服务器上。结果一上服务器就傻眼了:系统自带 Python 2.7,而 langgraph-cli 要求 Python 3.10+,uv 更是想都别想。服务器上既装不了 uv,也装不了 langgraph-cli,langgraph build 这条路直接堵死。
但需求摆在那里:代码必须上服务器,必须用 Docker 跑起来。最后摸索出一条路:在本地用 langgraph dockerfile 生成 Dockerfile,把生成物连同代码一起传到服务器,服务器上只用原生的 docker build 构建。服务器上完全不需要 Python 3,也不需要任何 LangGraph CLI。
这篇博客记录一下完整的踩坑过程和最终方案,如果你也卡在“本地能跑、服务器 Python 太老”的困境里,应该能省你几个小时。
一、为什么不能用 langgraph build?
langgraph build 本质上是一个封装好的便捷命令,它内部会做几件事:拉取基础镜像、生成 Dockerfile、执行 docker build。问题在于,这个命令必须在装有 langgraph-cli 的环境里运行,而 CLI 本身依赖现代 Python 版本。