install-python-api
它能做什么
这项技能安装让你的代码与 CARLA 模拟器通信的 Python 工具。适合想编写 Python 程序来控制或读取模拟的人。
适用场景
- ✓当你想编写 Python 代码来控制 CARLA 模拟器时。
- ✓当某个 CARLA 工具报错,提示无法导入 carla 包时。
- ✓当你有了新的模拟器版本,需要与之匹配的 Python 客户端时。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/setup/install-python-api/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能在我的电脑上安装 CARLA Python 客户端,以便我用 Python 控制模拟器吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查已安装的内容,选择与你的模拟器版本对应的源,并将其安装到你指定的 Python 环境中。然后它会确认客户端可以导入,如果服务器正在运行,还会检查版本是否一致。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Install the CARLA Python client
Paths.
scripts/…andreferences/…below are relative to the directory holding this SKILL.md. Your working directory is the user's project, not that directory, so prefix them with its absolute path or the command is not found.
The bootstrap step everything else in python-api depends on: without an
importable carla, every one of those skills stops at
FAIL cannot import carla. This skill fixes that, into the interpreter you
choose, and tells you when the client it installed does not match the
simulator you are running.
It is client-side only. Nothing here builds, launches or modifies a simulator.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: detect — what is installed, which sources exist, what matches
- [ ] Step 3: install — auto-picks the best source, then verifies
- [ ] Step 4: verify against a running server when you have one
- [ ] Step 5: record `PYTHON` with `set_config` — the other skills read it
Step 1: Check prerequisites
bash scripts/check_env.sh
Steps 2-4: detect, install, verify
source scripts/env.sh
python3 scripts/install_python_api.py detect
python3 scripts/install_python_api.py install # auto
python3 scripts/install_python_api.py install --dry-run # show the pip line only
python3 scripts/install_python_api.py install --source pypi --version 0.9.16
python3 scripts/install_python_api.py verify
install is a no-op when carla already imports (--force to reinstall), and
every path ends by importing carla in the target interpreter — a pip exit code
is not treated as proof.
Which interpreter (the part people get wrong)
PYTHON selects the target; it defaults to python3 on PATH, and it is the same
variable the rest of the python-api group uses, so one setting covers them all.
PYTHON=/path/to/venv/bin/python python3 scripts/install_python_api.py install
This matters when an agent runs the skill. If the MCP server was started with
uvx/pipx/npx, that launcher puts its own isolated environment first on
PATH, so bare python3 is the tool's interpreter — commonly a different minor
version, and never the one that talks to CARLA. Installing the client there
achieves nothing. check_env.sh recognises those paths and says so. Set PYTHON
in the MCP client's env block once:
"env": { "PYTHON": "/home/me/carla-venv/bin/python" }
Sources, and why the order is not arbitrary
auto walks them in this order:
| # | Source | When it applies | Why this rank |
|---|---|---|---|
| 1 | local wheel — <root>/PythonAPI/carla/dist/carla-*-<cp tag>-*.whl |
CARLA_PACKAGE_ROOT or CARLA_UE4_ROOT is set and ships one |
it is the only artifact guaranteed to match your simulator |
| 2 | PyPI — pip install carla==X.Y.Z |
any interpreter PyPI has a wheel for | clean and offline-free, but you must name the right version |
| 3 | egg — carla-*-py<X.Y>-*.egg |
older releases that ship an egg | nothing to install; it goes on PYTHONPATH (written as a .pth inside a venv) |
Not covered here: building from source — that is [[build-carla-ue4]] step 04
(make PythonAPI), the right answer when no wheel exists for your interpreter.
Conda and Docker distributions are also out of scope.
PyPI coverage is real but partial — detect prints the live matrix, e.g.
0.9.16 -> cp310, cp311, cp312 (linux + windows, no macOS wheels). Ask for an
interpreter it has no wheel for and the skill refuses before pip does, naming
the tags that exist.
Version matching
CARLA's client and simulator are expected to be the same version; a mismatch
produces WARNING: Client API version = X / Simulator API version = Y on every
connection and subtly missing API. So:
- source 1 (local wheel) inherits the version from the release you actually have;
detect/verifyquery a reachable server and reportmatchorMISMATCH;- a mismatch is a WARN, not a failure — it is often intentional (talking to a remote server), so the skill reports it and continues.
numpy<2 is pinned in the same pip transaction: CARLA's bindings are built
against the numpy 1.x C API and crash on import under 2.x.
Examples
Example 1: only a downloaded release, no client installed
User says: "I downloaded CARLA and pip install carla-agentic-tools, now what?"
export
常见问题
它使用哪个 Python 环境?
由你选择,因此它会安装到你其他 CARLA 工具所用的同一个 Python 中。
它会更改我的模拟器吗?
不会。它只在你的电脑上安装客户端,不会构建或更改模拟器。
如果我的客户端和模拟器版本不一致怎么办?
这项技能会告诉你版本不匹配,方便你在运行代码前修复。
详情
作者的原始描述
Installs the CARLA Python client (the `carla` package) into a chosen interpreter so the other python-api skills work — from a wheel bundled with your release or checkout, from PyPI (`pip install carla==X.Y.Z`), or by putting an older release's .egg on PYTHONPATH. Detects what is already present, picks the source that matches your simulator's version, pins numpy<2, and verifies `import carla` plus the client/server version match. Use when the user asks to "install the CARLA Python API", "pip install carla", "set up the carla python package", or when a skill reports "cannot import carla".
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11118
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
create-leaderboard-route
15k帮你的智能体通过在模拟器视角中放置路径点和场景触发器,构建 CARLA Leaderboard 路线文件,并对其进行检查和排序。
package-leaderboard-agent
15k帮你的智能体把驾驶智能体打包成 Docker 镜像,用于提交 CARLA Leaderboard,并检查文件夹结构,测试镜像能否加载它。
read-leaderboard-results
15k帮你的智能体阅读 CARLA Leaderboard 结果文件,解释每条路线的得分和违规情况,并按另一规则版本重新计分。
run-leaderboard-evaluation
15k帮你的智能体用你的驾驶智能体在一组路线上运行 CARLA Leaderboard 评估器,先检查设置,并保存可以恢复的检查点。